I'm working on a .Net client application that will consume a non .Net web service via SOAP standard, to calculate and post Sales Tax information for items. There is no .asmx. The web service is authored and maintained by a different group. They provided a WSDL url and said all the XSD schemas I need are present in it. The problem is, it is nested and daisy chained using xsd:import tags, a few levels deep.
I have the web service added to my Visual Studio 2012 Windows Forms project by "Add Service Reference". Calling this web service was not straight forward as it had some additional security requirements.
The web service has 3 operations - HeartBeat, Calculate, Post.
With my very limited knowledge of WCF and some help from another expert, I was able to call the heartbeat function successfully; this was the easiest because it takes no parameters.
My struggle is, how to structure the input to call the other two functions - Calculate and Post ? They both take a strongly typed object as input. How do I construct such a strongly typed object when this application(.Net) will be called by another one elsewhere?
At the moment, as an experiment, I'm constructing an object based on the proxy classes VS2012 created for the service reference, initializing and populating them with some values manually. Should I use XSD.exe to generate classes for the schemas from WSDL and populate them with the input by deserializing?
Below is the SOAP call to the calculate function. This works when invoked from SoapUI.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://MyCompany.com/svc/Finance/SalesTax/v1/">
<soap:Header/>
<soap:Body>
<v1:calculate>
<CalculateRequest>
<Context>
<!--Optional:-->
<SendingApplication>SoapUI</SendingApplication>
<!--Optional:-->
<UserId>SoapUI</UserId>
<!--Zero or more repetitions:-->
<LocaleCode>en</LocaleCode>
<!--Optional:-->
<ApplicationName>SoapUI</ApplicationName>
</Context>
<TaxRequestor>
<Name>Person X</Name>
<!--Optional:-->
<!--Optional:-->
<AdministrativeAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</AdministrativeAddress>
<CompanyNumber>1</CompanyNumber>
</TaxRequestor>
<Transaction>
<!--1 or more repetitions:-->
<LineItem>
<LineNumber>1</LineNumber>
<!--Optional:-->
<Item>
<!--Optional:-->
<Identifier>10134</Identifier>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">Product X</Name>
<!--Optional:-->
<TaxCode>9876</TaxCode>
<Department>
<!--Optional:-->
<Code>99</Code>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">?</Name>
</Department>
</Item>
<!--Optional:-->
<Quantity>10</Quantity>
<!--Optional:-->
<UnitPrice>
<Amount>1000</Amount>
</UnitPrice>
<ShipFromAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipFromAddress>
<ShipToAddress>
<Line1>1041 New York Rd</Line1>
<City>Newark</City>
<County>Essex</County>
<State>NJ</State>
<PostalCode>07054</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipToAddress>
<!--Zero or more repetitions:-->
<LineItemIdentifier>1</LineItemIdentifier>
</LineItem>
<LineItem>
<LineNumber>1</LineNumber>
<!--Optional:-->
<Item>
<!--Optional:-->
<Identifier>98765</Identifier>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">Product X</Name>
<!--Optional:-->
<TaxCode>Some Tax Code</TaxCode>
<Department>
<!--Optional:-->
<Code>99</Code>
</Department>
</Item>
<!--Optional:-->
<Quantity>10</Quantity>
<!--Optional:-->
<UnitPrice>
<Amount>1000</Amount>
</UnitPrice>
<ShipFromAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipFromAddress>
<ShipToAddress>
<Line1>1008 3rd St</Line1>
<City>Lewisville</City>
<County>Denton</County>
<State>TX</State>
<PostalCode>75010</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipToAddress>
<!--Zero or more repetitions:-->
<LineItemIdentifier>1</LineItemIdentifier>
</LineItem>
</Transaction>
</CalculateRequest>
</v1:calculate>
</soap:Body>
</soap:Envelope>
Please help with your advice and recommendations. Thank you. Using VS2012, .Net 4.5, C#
Related
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.
I am trying to consume a service .
Can any one help me how to generate a soap request as follows.
i want to construct a class and then serialize the class using soap formator and then post it to my service. I tried with the some online help but could not able to generate the required soap xml.
i am bit confused about the implementation .Can any one help me on this.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iot="http://services.singp.com>
<soapenv:Header/>
<soapenv:Body>
<iot.performService>
<iot.input>
<iot.gsh><![CDATA[
<header xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://services.singp.com">
<GUID></GUID>
<CustID></CustID>
<RequestName></RequestName>
<TimeStamp>2017-06-09T10:49:03.49-05:00</TimeStamp>
</header>
]]></iot.gsh>
<iot.Body><![CDATA[
<CustStatus xmlns="http://services.singp.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CustStatusAttributes>
<CustID>str1234</CustID>
<Action>str1234</Action>
</CustStatusAttributes>
<CustStatusInformation>
<ClientOrderNumber>745</ClientOrderNumber>
</CustStatusInformation>
</CustStatus>
]]></iot.Body>
</iot.input>
</iot.performService>
</soapenv:Body>
</soapenv:Envelope>
I have a webservice from a partner that am developing against in C#. I have browsed it on SOAPUI and this is the request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ser="http://service.bank.pmt.tpa" xmlns:xsd="http://bean.bank.pmt.tpa/xsd">
<soapenv:Header/>
<soapenv:Body>
<ser:processPaymentNotificationReport>
<!--Zero or more repetitions:-->
<ser:pmtNotifyReport>
<!--Optional:-->
<xsd:amountPaid>?</xsd:amountPaid>
<!--Optional:-->
<xsd:bankBranchCode>?</xsd:bankBranchCode>
<!--Optional:-->
<xsd:bankTransNo>?</xsd:bankTransNo>
<!--Optional:-->
<xsd:datePaid>?</xsd:datePaid>
<!--Optional:-->
<xsd:paymentRegTransNo>?</xsd:paymentRegTransNo>
<!--Optional:-->
<xsd:status>?</xsd:status>
<!--Optional:-->
<xsd:taxPayerName>?</xsd:taxPayerName>
<!--Optional:-->
<xsd:tin>?</xsd:tin>
<!--Optional:-->
<xsd:transactionId>?</xsd:transactionId>
</ser:pmtNotifyReport>
</ser:processPaymentNotificationReport>
when i input the parameters and browse, this is the response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>wsse:InvalidSecurity</faultcode>
<faultstring>Missing wsse:Security header in request</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I have reconstructed the request xml in my code then send the xml to the partner by invoking their url. Now i find out that i cannot hit their webservice until i implement the security certificate. I have no idea how i can import that security certificate and use it in my code, need some help pease.
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>
I have a problem with some calls to a web service:
When I create the SoapEnveloper I put this on the wire
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:GetUserIDByName>
<tem:sUser>sample</tem:sUser>
<tem:oParam>
<tem:CountryURL>US</tem:CountryURL>
<tem:noCache>false</tem:noCache>
</tem:oParam>
</tem:GetUserIDByName>
</soapenv:Body>
</soapenv:Envelope>
But the response comes as:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:16092960528611E1BFADB7181697B03B</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
<wsa:ReferenceParameters>
<instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">0000JLUJsMq0VsSqyCBh6G1FCdSn000GYf</instra:tracking.ecid>
</wsa:ReferenceParameters>
</wsa:ReplyTo>
</env:Header>
<env:Body>
<GetUserIDByNameResponse xmlns="http://tempuri.org/">
<Error>
<ErrorCode>0</ErrorCode>
<ErrorMessage>''</ErrorMessage>
</Error>
<ReturnValue>0</ReturnValue>
<GetUserIDByNameResult>9815</GetUserIDByNameResult>
</GetUserIDByNameResponse>
</env:Body>
</env:Envelope>
Now the autogenerated proxy classes for this service call has the following attribute:
[SoapDocumentMethodAttribute("http://tempuri.org//GetUserNameById",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
corresponding to the default namespace.
The problem seems that the de-serialization process does not seem to understand the response.
Any idea on how to fix this?