Connected service does not parse SOAP response correctly - c#

I am working with this SOAP web service in a .NET Framework project. I inspect the XML content of requests and responses, and everything looks good. But the SOAP client (the one Visual Studio creates via Connected Services thing) does not map the response correctly to the entity class.
Here is the request XML.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">OrderList</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<OrderListRequest xmlns="http://www.n11.com/ws/schemas">
<auth xmlns="">
<appKey>**redacted**</appKey>
<appSecret>**redacted**</appSecret>
</auth>
<searchData xmlns="">
<productId xsi:nil="true" />
<status xsi:nil="true" />
<orderNumber>**redacted**</orderNumber>
<productSellerCode xsi:nil="true" />
<sameDayDelivery xsi:nil="true" />
<sortForUpdateDate>false</sortForUpdateDate>
</searchData>
<pagingData xsi:nil="true" xmlns="" />
</OrderListRequest>
</s:Body>
</s:Envelope>
And here is the response.
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header />
<env:Body>
<ns3:OrderListResponse xmlns="" xmlns:ns3="http://www.n11.com/ws/schemas">
<result>
<status>success</status>
</result>
<pagingData>
<currentPage>0</currentPage>
<pageSize>100</pageSize>
<totalCount>1</totalCount>
<pageCount>1</pageCount>
</pagingData>
<orderList>
<order>
<citizenshipId>**redacted**</citizenshipId>
<createDate>02/10/2020 14:46</createDate>
<id>**redacted**</id>
<orderNumber>**redacted**</orderNumber>
<paymentType>1</paymentType>
<status>2</status>
</order>
</orderList>
</ns3:OrderListResponse>
</env:Body>
</env:Envelope>
As it is visible in the response XML, I get all the information I want perfectly. But as you can see in the screenshot below, all I'm getting in the response object is the citizenshipId, and everything else is either null or the default value for its type.
What could be the problem here? I'm a newbie in .NET so I don't even know how to Google this. I tried a few searches but nothing yielded any related results.
The WSDL is publicly available at https://api.n11.com/ws/OrderService.wsdl.

Related

EWS Managed API Error - An object within a change description must contain one and only one property to modify

Any ideas why exchange keeps throwing this error?
I'm using Microsoft Exchange Managed API 2.0, from C#.
The sample request and responses are intercepted using Fiddler
I'll post a request and response sample.
I even tried to remove all properties and leave just a simple one, and still same error.
It doesn't seem to be a collections related issue
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADgwNWY5NDQ3LWRkMTQtNGQyZS04ODMxLTQzMDQ1NWU5NTI2OABGAAAAAADzrqMpUzgAQoRJwq9Jq9ArBwDjC+q0IBppSKdYNLEIzckAAADAlx38AADjC+q0IBppSKdYNLEIzckAAADAly/BAAA=" ChangeKey="EQAAABYAAADjC+q0IBppSKdYNLEIzckAAADAis/g" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:GivenName" />
<t:Contact>
<t:GivenName>Mickeyaabsbbcdsf</t:GivenName>
</t:Contact>
</t:SetItemField>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:FileAs" />
<t:Contact />
</t:SetItemField>
<t:DeleteItemField>
<t:FieldURI FieldURI="contacts:FileAs" />
</t:DeleteItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="20" MajorBuildNumber="2241" MinorBuildNumber="12" Version="V2018_01_08"/>
</s:Header>
<s:Body>
<m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:UpdateItemResponseMessage ResponseClass="Error">
<m:MessageText>An object within a change description must contain one and only one property to modify.</m:MessageText>
<m:ResponseCode>ErrorIncorrectUpdatePropertyCount</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:MessageXml>
<t:Value Name="PropertyCount">0</t:Value>
<t:Value Name="PropertyInfo"/>
</m:MessageXml>
<m:Items/>
</m:UpdateItemResponseMessage>
</m:ResponseMessages>
</m:UpdateItemResponse>
</s:Body>
</s:Envelope>
Turns out the problem is, I am performing 2 operations on the "FileAs" field.
At some point in the code I assigned a value to it, use that value somewhere else in the flow, and then making it null, like it was.
This, in turns, triggers a state change in the object that holds the property.
The contact objects sees that I did an assignment, and then a null, which equals deleting the value.
This double state change is confusing for exchange, because it doesn't know which of the 2 state changes is the correct one that should be persisted in Exchange, therefore, triggering that error.
So all in all, avoid doing this in the code!
contact.FileAs = "SomeValue"
........
contact.FileAs = null;
You can also see the confusing effect it has on the request xml (it does a set item field, with no value, and then a delete item field)
<t:SetItemField>
<t:FieldURI FieldURI="contacts:FileAs" />
<t:Contact />
</t:SetItemField>
<t:DeleteItemField>
<t:FieldURI FieldURI="contacts:FileAs" />
</t:DeleteItemField>

VS Generated WSDL Namespace Issues

Good Afternoon,
We have been trying to consume a Carrier API, but have hit some issue with the WSDL Generation. The Example XML message the company has provided has ns1-3 and appears that it is important for the address fields. the XML generated from their WSDL seems to generate the same fields but has no name spaces like the original and fails with "Address details are invalid", Is there some setting we are missing so that it generates the correct XML?
This is their Example XML
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns3:CreateLabel xmlns:ns3="http://courier.ck.dx.metafour.com/" xmlns:ns2="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<order>
<ns2:customerID>14337622</ns2:customerID>
<ns2:dates>
<date format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2018-12-12 17:59:21</date>
</ns2:dates>
<sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
<customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
<orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
<ns2:orderLines>
<ns2:consignment>
<pieces>
<dimensions>
<value>1.0</value>
<type>cdlWeight</type>
<UOM>KG</UOM>
</dimensions>
<barcode xsi:nil="true" />
<trackingNumber xsi:nil="true" />
</pieces>
<qty>1</qty>
<legacyService>
<name>serviceLevel</name>
<partyId>0</partyId>
<partyType>HITS</partyType>
</legacyService>
<legacyService>
<name>serviceType</name>
<partyId>2</partyId>
<partyType>HITS</partyType>
</legacyService>
<deliverTo>
<ns2:address primary="true">
<organisationName>Argos</organisationName>
<addressLine1>Argos</addressLine1>
<addressLine2>Argos Ltd</addressLine2>
<addressLine3>11 Canning Street</addressLine3>
<city>BURNLEY</city>
<postalCode>BB12 0AD</postalCode>
<country>
<countryCode>GB</countryCode>
<description>GB</description>
</country>
</ns2:address>
<contact />
</deliverTo>
</ns2:consignment>
</ns2:orderLines>
<labelType>ZPL</labelType>
</order>
<serviceHeader>
<password>test</password>
<userId>test</userId>
</serviceHeader>
</ns3:CreateLabel>
</s:Body>
</s:Envelope>
This is our Generated XML
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateLabel xmlns="http://courier.ck.dx.metafour.com/">
<order xmlns="">
<customerID xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">14337622</customerID>
<dates xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<date xmlns="" format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2019-01-25 10:17:33</date>
</dates>
<sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
<customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
<orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
<orderLines xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<consignment>
<pieces xmlns="">
<dimensions>
<value>1.0</value>
<type>cdlWeight</type>
<UOM>KG</UOM>
</dimensions>
<barcode xsi:nil="true" />
<trackingNumber xsi:nil="true" />
</pieces>
<qty>1</qty>
<legacyService xmlns="">
<name>serviceLevel</name>
<partyId>0</partyId>
<partyType>HITS</partyType>
</legacyService>
<legacyService xmlns="">
<name>serviceType</name>
<partyId>2</partyId>
<partyType>HITS</partyType>
</legacyService>
<deliverTo xmlns="">
<address xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<organisationName xmlns="">Argos</organisationName>
<addressLine1 xmlns="">Argos</addressLine1>
<addressLine2 xmlns="">Argos Ltd</addressLine2>
<addressLine3 xmlns="">11 Canning Street</addressLine3>
<city xmlns="">BURNLEY</city>
<postalCode xmlns="">BB12 0AD</postalCode>
<country xmlns="">
<countryCode>GB</countryCode>
<description>GB</description>
</country>
</address>
<contact xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" />
</deliverTo>
</consignment>
</orderLines>
<labelType>ZPL</labelType>
</order>
<serviceHeader xmlns="">
<password>test</password>
<userId>test</userId>
</serviceHeader>
</CreateLabel>
</s:Body>
</s:Envelope>
Any help would be greatly appreciated!
This is resolved,
I could not figure out a way to change or add additional namespace to the generated references.cs file, and ended up sending the SOAP to their server manually with an XML string serialized using a httpWebRequest and XmlSerializer

EWS - determine if an attendee is a room or resource instead of a person

Given an Attendee in EWS, how can I determine if that attendee is a room or a resource, instead of a person?
The first thing would be just check if the Attendee is in the Resources Strongly typed property https://msdn.microsoft.com/en-us/library/exchangewebservices.calendaritemtype.resources(v=exchg.80).aspx if your getting a Calendar Item using EWS this is where Rooms and Resources will be returned vs Required and optional attendees.
If the Attendee is in the Global Address list and you have 2013 or greater then you can also use FindPeople and check the PersonaType returned eg
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body >
<m:FindPeople>
<m:PersonaShape>
<t:BaseShape>Default</t:BaseShape>
</m:PersonaShape>
<m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="100" Offset="0"/>
<m:ParentFolderId>
<t:DistinguishedFolderId Id="directory"/>
</m:ParentFolderId>
<m:QueryString>Adams#ddddd.onmicrosoft.com</m:QueryString>
</m:FindPeople>
</soap:Body>
</soap:Envelope>
should return something like the following for a room
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="629" MinorBuildNumber="8" Version="V2016_07_13" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body>
<FindPeopleResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ResponseCode>NoError</ResponseCode>
<People>
<Persona xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PersonaId Id="AAUQAGDlxBsmUDpClBbAI1WX04o=" />
<PersonaType>Room</PersonaType>
<CreationTime>0001-01-02T00:00:00Z</CreationTime>
<DisplayName>Conf Room Adams</DisplayName>
<DisplayNameFirstLast>Conf Room Adams</DisplayNameFirstLast>
<DisplayNameLastFirst>Conf Room Adams</DisplayNameLastFirst>
<FileAs />
<EmailAddress>
<Name>Conf Room Adams</Name>
<EmailAddress>Adams#dddddd.onmicrosoft.com</EmailAddress>
<RoutingType>SMTP</RoutingType>
<MailboxType>Mailbox</MailboxType>
</EmailAddress>
<EmailAddresses>
<Address>
<Name>Conf Room Adams</Name>
<EmailAddress>Adams#dddddd.onmicrosoft.com</EmailAddress>
<RoutingType>SMTP</RoutingType>
<MailboxType>Mailbox</MailboxType>
</Address>
</EmailAddresses>
<RelevanceScore>2147483647</RelevanceScore>
</Persona>
</People>
<TotalNumberOfPeopleInView>0</TotalNumberOfPeopleInView>
<FirstMatchingRowIndex>0</FirstMatchingRowIndex>
<FirstLoadedRowIndex>0</FirstLoadedRowIndex>
</FindPeopleResponse>
</s:Body>
</s:Envelope>

How to create SOAP XML request message for paypal CreateInvoice api using c#

I have created a sandbox test accounts for PayPal.
I want to consume the PayPal api CreateInvoice,SendInvoice and CreateAndSendInvoice using SOAP xml format in C#. The documentation from x.com, doesn't show any completed request message at least in basic soap xml format, instead, it shows only the header part and definitions for soap xml tags.
Some examples are in JSON format but its not my preferred format,its light-weight but human readable. SDK's are using NVP format, although they have SOAP option but the codes are not able to compose the soap xml format for the payload.
I need the completed soap xml request message with at least the required fields to createinvoice.
I'm still searching stackoverflow so far.
The API reference provides a graphical representation of the SOAP request. For example, you can take a look at CreateAndSendInvoice and see all of the tags that could be included in your XML/SOAP request as well as how everything should be nested.
If you're going to be building the XML yourself as oppose to using a WSDL there's really no need to format it for SOAP. Here's a sample of an XML Request for CreateInvoice that I just ran successfully...
<?xml version="1.0" encoding="utf-8"?>
<CreateInvoiceRequest xmlns="http://svcs.paypal.com/types/ap">
<requestEnvelope xmlns="">
<detailLevel>ReturnAll</detailLevel>
<errorLanguage>en_US</errorLanguage>
</requestEnvelope>
<invoice xmlns="">
<merchantEmail xmlns="">sandbo_1215254764_biz#angelleye.com</merchantEmail>
<payerEmail xmlns="">sandbo_1204199080_biz#angelleye.com</payerEmail>
<number xmlns="">12Z3-ABCDE</number>
<merchantInfo xmlns="">
<firstName xmlns="">Tester</firstName>
<lastName xmlns="">Testerson</lastName>
<businessName xmlns="">Testers, LLC</businessName>
<phone xmlns="">555-555-5555</phone>
<fax xmlns="">555-555-5556</fax>
<website xmlns="">http://www.domain.com</website>
<customValue xmlns="">Some custom info.</customValue>
<address xmlns="">
<line1 xmlns="">123 Main St.</line1>
<city xmlns="">Grandview</city>
<state xmlns="">MO</state>
<postalCode xmlns="">64030</postalCode>
<countryCode xmlns="">US</countryCode>
</address>
</merchantInfo>
<itemList xmlns=""><item xmlns="">
<name xmlns="">Test Widget 1</name>
<description xmlns="">This is a test widget #1</description>
<date xmlns="">2012-02-18</date>
<quantity xmlns="">1</quantity>
<unitPrice xmlns="">10.00</unitPrice>
</item><item xmlns="">
<name xmlns="">Test Widget 2</name>
<description xmlns="">This is a test widget #2</description>
<date xmlns="">2012-02-18</date>
<quantity xmlns="">2</quantity>
<unitPrice xmlns="">20.00</unitPrice>
</item></itemList>
<currencyCode xmlns="">USD</currencyCode>
<paymentTerms xmlns="">DueOnReceipt</paymentTerms>
<note xmlns="">This is a test invoice.</note>
<merchantMemo xmlns="">This is a test invoice.</merchantMemo>
<billingInfo xmlns="">
<firstName xmlns="">Tester</firstName>
<lastName xmlns="">Testerson</lastName>
<businessName xmlns="">Testers, LLC</businessName>
<phone xmlns="">555-555-5555</phone>
<fax xmlns="">555-555-5556</fax>
<website xmlns="">http://www.domain.com</website>
<customValue xmlns="">Some custom info.</customValue>
<address xmlns="">
<line1 xmlns="">123 Main St.</line1>
<city xmlns="">Grandview</city>
<state xmlns="">MO</state>
<postalCode xmlns="">64030</postalCode>
<countryCode xmlns="">US</countryCode>
</address>
</billingInfo>
<shippingInfo xmlns="">
<firstName xmlns="">Tester</firstName>
<lastName xmlns="">Testerson</lastName>
<businessName xmlns="">Testers, LLC</businessName>
<phone xmlns="">555-555-5555</phone>
<fax xmlns="">555-555-5556</fax>
<website xmlns="">http://www.domain.com</website>
<customValue xmlns="">Some custom info.</customValue>
<address xmlns="">
<line1 xmlns="">123 Main St.</line1>
<city xmlns="">Grandview</city>
<state xmlns="">MO</state>
<postalCode xmlns="">64030</postalCode>
<countryCode xmlns="">US</countryCode>
</address>
</shippingInfo>
<shippingAmount xmlns="">10.00</shippingAmount>
<logoUrl xmlns="">https://www.usbswiper.com/images/angelley-clients/cpp-header-image.jpg</logoUrl>
<referrerCode xmlns="">AngellEYE_PHPClass</referrerCode>
</invoice>
</CreateInvoiceRequest>

How can I configure SOAP XML namespaces in web service client request?

I am having trouble calling a 3rd party web-service. I have not received a SOAP fault, but am not getting a valid resultset. A colleague of mine has written a client in RPG on the OS400 and it returns a valid resultset. When comparing the RAW request in Fiddler2 for both requests, the only glaring difference I noticed was that my c# client had SOAP xml elements with xmlns="" and his did not. Is it possible to remove said empty namespace declarations? Please see the referenced SOAP request below:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SendArchitectServiceRequest xmlns="archserver.xsd.dataflux.com">
<serviceName xmlns="">AddressVerify.dmc</serviceName>
<fieldDefinitions xmlns="">
<fieldName>AddressLine_1</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<fieldDefinitions xmlns="">
<fieldName>AddressLine_2</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<fieldDefinitions xmlns="">
<fieldName>City_in</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<fieldDefinitions xmlns="">
<fieldName>State_in</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<fieldDefinitions xmlns="">
<fieldName>Zip</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<fieldDefinitions xmlns="">
<fieldName>Country</fieldName>
<fieldType>STRING</fieldType>
<fieldLength>255</fieldLength>
</fieldDefinitions>
<dataRows xmlns="">
<value>3485 W. Harmon Ave.</value>
<value/>
<value>Las Vegas</value>
<value>NV</value>
<value>89103</value>
<value>United States</value>
<reserved>0</reserved>
</dataRows>
</SendArchitectServiceRequest>
</s:Body>
</s:Envelope>
Your proposed method seems like the easiest approach. One other approach would be to use SOAP extensions to modifiy the SOAP response, removing the empty xmlns attribute. You would modify the SoapClientMessage in the BeforeDeserialize stage of the SoapMessageStage.
Since I have not heard any comments or answers to my second question, I will accept the answer I came across which was altering the auto-generated Reference.cs class XML element declarations from System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified) to System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified).

Categories