Good day all, I am consuming soap 1.1 service built on Apache axis via WCF client. Issue is that both fault and normal response are not parsed by built in deserilizer of WCF and i am getting an exception related to XML parsing when calling a web operation via wcf client. When I inspect the message I got this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soapenv:Body>
<V2Response xmlns="urn:ETS">
<V2Return xsi:type="ns1:TResponse" xmlns:ns1="urn:ETS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fulfilmentRef></fulfilmentRef>
<paymentRef></paymentRef>
<statusCode>2013</statusCode>
<statusDescription>ePayments: Invalid client password specified in request.</statusDescription>
<transactionId xsi:nil="true" />
<transactionTimeStamp>2013-06-21T08:22:16.483Z</transactionTimeStamp>
</V2Return>
</V2Response>
</soapenv:Body>
</soapenv:Envelope>
The exception which I am getting is:
> The specified type was not recognized: name='TResponse', namespace='urn:ETS', at <V2Return xmlns='urn:ETS'>
I have a valid TResponse class in Reference.cs, please let me know if this can be handled by changing configurations, I was expecting WCF client to parse any soap message but it couldn't, I cannot change anything on server side, it is the 3rd party api.
I am able to solve this problem by changing namespace manually in proxy class generated by svcutil.exe. "TResponse" class have some different namespace defined in proxy code, when i changed namespace to urn:ETS, soap response easily deserialized into class. Before that i have checked the response from SoapUI and validated soap response and everything was looking perfect, then i searched on SO and found This url. After reading the exception again I realized that issue is in the namespace.
Below is change which i did:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://axis.webservices.api.etransactions")]
public partial class TResponse : object, System.ComponentModel.INotifyPropertyChanged {
........
I replaced "http://axis.webservices.api.etransactions" with "urn:ETransactionsService" and it worked, :)!
Related
I have one XSD which in turn use multiple XSDs. I have generated .cs file using XSD.exe. Webservice Operation which i would like to call expect request XML is of this class type. Problem i am facing is that host of this webservice expect a XML with soap envelope and Soap Body. When i have generated XML using serializing the object of .cs file, it does not have soap envelope and body.
I have tried finding this on net but nothing fruitful found.
Expected XML:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>testuser</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">testwelcome1</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header>
<soap:Body xmlns:ns1="http://capabilities.nat.bt.com/xsd/EDM/EMP/ManageDocument/CreateFolder">
<ns1:CreateFolderRequest xmlns:ns2="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:ns3="http://capabilities.nat.bt.com/xsd/EDM/EMP/ManageDocument/Header/1.0">
<ns2:standardHeader>
<ns2:serviceState>
<ns2:stateCode>OK</ns2:stateCode>
</ns2:serviceState>
<ns2:serviceAddressing>
<ns2:from>Dummy</ns2:from>
<ns2:to>
<ns2:address>Dummy/ns2:address>
</ns2:to>
<ns2:replyTo>
<ns2:address>Dummy</ns2:address>
</ns2:replyTo>
<ns2:messageId>MessageID1</ns2:messageId>
<ns2:serviceName>Dummy</ns2:serviceName>
<ns2:action>AddDocumentRequest</ns2:action>
</ns2:serviceAddressing>
</ns2:standardHeader>
<ns3:HeaderRequest>
<ns3:AccountID>sharePoint_user</ns3:AccountID>
<ns3:Password>Dummy</ns3:Password>
<ns3:Domain>Dummy</ns3:Domain>
</ns3:HeaderRequest>
<ns1:RepositoryID>Dummy</ns1:RepositoryID>
<ns1:FolderName>test_test_test_1</ns1:FolderName>
<ns1:ParentID>null</ns1:ParentID>
<ns1:CreatedDate>2012-03-02</ns1:CreatedDate>
<ns1:OwnerID>null</ns1:OwnerID>
<ns1:ParentPath>Test_Folder</ns1:ParentPath>
</ns1:CreateFolderRequest>
</soap:Body>
</soap:Envelope>
Please help. sorry but i am new to this SOAP thing.
Question:
Why would I receive a SOAP response fragment that contains a duplicate tag prefix namespace?
Why would I receive a different response fragment in SoapUI versus a WCF client using the exact same SOAP request?
Context:
I am calling a third-party, Java based web service with a WCF client. The SOAP fragment response sent from the third party WS contains a duplicate namespace and tag prefix for the soap envelope on the Fault tag line when calling with an incorrect value that results in a fault response. This causes the WCF to throw a CommunicationException with an innerException of XmlException which cites the following as the error:
Start element 'faultcode' from namespace '' expected. Found element 'SOAP-ENV:faultcode'
from namespace 'http://schemas.xmlsoap.org/soap/envelope/'.
This error message leads me to believe the duplicated namespace in the SOAP fragment is the culprit. The weird thing is, using the exact SOAP request sent from the WCF client to the web service in SoapUI does not result in this namespace being duplicated in the SOAP response fragment.
The WCF client is using a basicHttpBinding.
Please see below for SOAP fragments of the request, response through WCF, and response through SoapUI.
Request sent by both WCF and SoapUI:
<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">
<Search xmlns="urn:ent.soap.testservice.com/objs">
<Request objType="Report">
<RequestorId>ABCD</RequestorId>
<TargetId></TargetId>
</Request>
</Search>
</s:Body>
</s:Envelope>
Response received by WCF client:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:faultcode>SOAP-ENV:Server</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>Invalid action parameters</SOAP-ENV:faultstring>
<SOAP-ENV:detail>
<fns:fault xmlns:fns="urn:fault.soap.testservice.com" xmlns:java="java" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="fns:ApiFault">
<fns:exceptionCode>INTERNAL_ERROR</fns:exceptionCode>
<fns:exceptionMessage>Invalid action parameters</fns:exceptionMessage>
<fns:logDataExchangeId>1234567890</fns:logDataExchangeId>
</fns:fault>
</SOAP-ENV:detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response received by SoapUI:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<SOAP-ENV:faultcode>SOAP-ENV:Server</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>Invalid action parameters</SOAP-ENV:faultstring>
<SOAP-ENV:detail>
<fns:fault xsi:type="fns:ApiFault" xmlns:fns="urn:fault.soap.testservice.com" xmlns:java="java" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fns:exceptionCode>INTERNAL_ERROR</fns:exceptionCode>
<fns:exceptionMessage>Invalid action parameters</fns:exceptionMessage>
<fns:logDataExchangeId>1234567890</fns:logDataExchangeId>
</fns:fault>
</SOAP-ENV:detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem is not the duplicated namespace declaration. The problem is in this bit:
<SOAP-ENV:faultcode>SOAP-ENV:Server</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>Invalid action parameters</SOAP-ENV:faultstring>
On the SOAP Specification, the faultcode and faultstring elements are in the empty, default namespace, not in the "http://schemas.xmlsoap.org/soap/envelope/" namespace. So it really should've looked something like this:
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:MustUnderstand</faultcode>
<faultstring>SOAP Must Understand Error</faultstring>
</SOAP-ENV:Fault>
So looks like this service in particular is not being compliant with the SOAP 1.1 (or 1.2 for that matter) specification.
Im trying to setup a connect listener. I am currently using a C# WCF Service that Im hosting on Azure. Im able to hit my service method but the response from docusign is null every time. In the logs, the envelope status xml has values but it is just not sent or not deserialized correctly. Im not sure what I am doing wrong and there doesnt seem to be any solid examples of a SOAP implementation anywhere. Can anyone help? The WSDL can be viewed here http://docusignconnectservice.azurewebsites.net/Service.svc?wsdl
Service Implentation
public string DocuSignConnectUpdate(DocuSignAPI.DocuSignEnvelopeInformation envelopeInformation)
{
string envelopeId = "";
if (envelopeInformation == null) return "Envelope is null";
else return envelopeInformation.EnvelopeStatus.EnvelopeID;
}
Service Contract
[ServiceContract(Namespace = "http://www.docusign.net/API/3.0")]
public interface IService
{
[OperationContract]
[XmlSerializerFormatAttribute]
string DocuSignConnectUpdate(DocuSignAPI.DocuSignEnvelopeInformation envelopeInformation);
[OperationContract]
string HelloWorld(string inputString);
DocuSign log entry
10/6/2014 1:30:12 AM Envelope Data:<?xml version="1.0" encoding="utf-8"?><DocuSignEnvelopeInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.net/API/3.0"><EnvelopeStatus><RecipientStatuses><RecipientStatus><Type>Signer</Type><Email>email</Email><UserName>Username</UserName><RoutingOrder>1</RoutingOrder><Sent>2014-10-05T17:49:36.58</Sent><DeclineReason xsi:nil="true" /><Status>Sent</Status><RecipientIPAddress /><CustomFields /><AccountStatus>Active</AccountStatus><RecipientId>2a10b0ab-63f1-4df9-9258-36b97b5db120</RecipientId></RecipientStatus></RecipientStatuses><TimeGenerated>2014-10-05T18:30:09.644588</TimeGenerated><EnvelopeID>6d7692e6-3f5c-4889-914f-942b2bd83447</EnvelopeID><Subject> Signature Request on Document</Subject><UserName>Username</UserName><Email>email</Email><Status>Sent</Status><Created>2014-10-05T17:49:35.503</Created> <Sent>2014-10-05T17:49:36.613</Sent><ACStatus>Original</ACStatus><ACStatusDate>2014-10-05T17:49:35.503</ACStatusDate><ACHolder></ACHolder><ACHolderEmail></ACHolderEmail><ACHolderLocation>DocuSign</ACHolderLocation><SigningLocation>Online</SigningLocation><SenderIPAddress>ip </SenderIPAddress><EnvelopePDFHash /><CustomFields /><AutoNavigation>true</AutoNavigation><EnvelopeIdStamping>true</EnvelopeIdStamping><AuthoritativeCopy>false</AuthoritativeCopy><DocumentStatuses><DocumentStatus><ID>1</ID><Name>F_1040.pdf</Name><TemplateName /><Sequence>1</Sequence></DocumentStatus></DocumentStatuses></EnvelopeStatus></DocuSignEnvelopeInformation>
10/6/2014 1:30:12 AM Response: <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"><DocuSignConnectUpdateResponse xmlns="http://www.docusign.net/API/3.0"><DocuSignConnectUpdateResult>Envelope is null</DocuSignConnectUpdateResult></DocuSignConnectUpdateResponse></s:Body> </s:Envelope>
I think there is problem with your classes for mapping of XML.
You can configure your classes with XML response you have with online tools like http://xmltocsharp.azurewebsites.net/ and use XMLSerializer to parse that XML into object .
I am calling a Java WebLogic web service from my .Net application. I have added a service reference to the jws service.
The service can be called fine and I can see the response in Fiddler, however the problem is that the propery listOfHolds is coming as null although I can see a list of holds in the XML of the response.
Here is the code for calling
holdsList result = proxy.viewHoldsList(request.AccountNo);
int noOfHolds = result.NumberOfHolds; // This value is read fine
object[] holds = result.listOfHolds; // This is coming as Null despite the values in the response
Here is the response XML as captured by Fiddler
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<work:WorkContext xmlns:work="http://oracle.com/weblogic/soap/workarea/">rO0...AAA</work:WorkContext>
</S:Header>
<S:Body>
<ns0:viewHoldsListResponse xmlns:ns0="http://www.openuri.org/">
<ns0:viewHoldsListResult>
<ns0:TotalAmount>130.0</ns0:TotalAmount>
<ns0:NumberOfHolds>4</ns0:NumberOfHolds>
<ns0:listOfHolds>
<ns0:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:holdDetails">
<ns0:xsiType>HoldDetails</ns0:xsiType>
<ns0:Amount>100.0</ns0:Amount>
<ns0:StartDate>2014-02-15T00:00:00.0</ns0:StartDate>
<ns0:ExpiryDate>2014-02-20T00:00:00.0</ns0:ExpiryDate>
<ns0:Description>For testing</ns0:Description>
<ns0:Instruction/>
<ns0:Tracer>00000810000287294002</ns0:Tracer>
<ns0:HoldId>3591376655</ns0:HoldId>
<ns0:EmployeeId>0</ns0:EmployeeId>
</ns0:item>
<ns0:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:holdDetails">
<ns0:xsiType>HoldDetails</ns0:xsiType>
<ns0:Amount>10.0</ns0:Amount>
<ns0:StartDate>2014-02-15T00:00:00.0</ns0:StartDate>
<ns0:ExpiryDate>2014-02-17T00:00:00.0</ns0:ExpiryDate>
<ns0:Description>DESC</ns0:Description>
<ns0:Instruction/>
<ns0:Tracer>00000810000287294004</ns0:Tracer>
<ns0:HoldId>3591376656</ns0:HoldId>
<ns0:EmployeeId>0</ns0:EmployeeId>
</ns0:item>
</ns0:listOfHolds>
</ns0:viewHoldsListResult>
</ns0:viewHoldsListResponse>
</S:Body>
</S:Envelope>
I have faced a similar problem before and the problem was a missing xmlns attribute on one of the tags. In this case I am suspecting the extra <ns0:xsiType>HoldDetails</ns0:xsiType> tag that is coming under the <ns0:item> tag.
Update Even after the web service provider removed the extra <xsiType> tag, I am unable to read the listOfHolds.
My questions are:
Can I do anything in my .Net code so that I get the intended value for listOfHolds?
Can I suggest any change to the owner of the Java web service?
[Optional] Why NumberOfHolds is being successfully read from the response but not listOfHolds?
The vendor of the web service has made a change. They changed xsi:type="ns0:holdDetails" to xsi:type="ns0:HoldDetails" (H instead of h).
The point is in Java, and unlike .Net as far as I can tell, they have a control over the generated XML from the web service.
I'm having some problems with one webservice that i'm working with. I generated a proxy class with wsdl.exe that comes with .net framework. But that webservice return a header that isnt not mapped by the wsdl. I must map the header sop because it contains some properties that i have to read and work with. how can i read the soap's header collection?
Ex.:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns="http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd">
<Session>
<SessionId>545784545</SessionId>
<SequenceNumber>1</SequenceNumber>
<SecurityToken>asd7a87sda89sd45as4d5a4</SecurityToken>
</Session>
</soap:Header>
<soap:Body>
<TAM_Altea_Seguranca_AutenticarRS xmlns="http://xml.amadeus.com/2009/04/TAM/TAM_Altea_Seguranca_AutenticarRS_2.0">
<statusDoProcesso>
<codigoDoStatus>P</codigoDoStatus>
</statusDoProcesso>
</TAM_Altea_Seguranca_AutenticarRS>
</soap:Body>
</soap:Envelope>
I need to read the SOAP:HEADER -> Session.
Have you tried this?
source: Handle SOAP Headers Required by an XML Web Service Client
public class MyWebService
{
public SoapUnknownHeader[] unknownHeaders;
[WebMethod]
[SoapHeader("unknownHeaders")]
public string MyWebMethod()
{
foreach (SoapUnknownHeader header in unknownHeaders)
{
// process headers
}
// handle request
}
}
See this page for detailed instructions on defining custom SOAP headers. There only seem to be VB.net code examples, but it should be easy enough to translate the principles in C#.