Based on the following SOAP XML message how can serialize this xml to serialize and extract all elements within the ReviewCallbackMessage into a single XElement? The SOAP Message coming in is using MTom encoding. I hope someone can shed some light on this. It seems like a flaw within WCF, but maybe it's something w/ my contract settings.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:oasis:names:tc:legalxml:wsdl:WebServicesProfile-Definitions-4.0">
<soapenv:Header/>
<soapenv:Body>
<NotifyCompleteRequestMessage xmlns="urn:oasis:names:tc:legalxml:wsdl:WebServicesProfile-Definitions-4.0">
<SendingMDELocationID xmlns="urn:oasis:names:tc:legalxml:schema:xsd:CommonTypes-4.0">
<IdentificationID xmlns="http://niem.gov/niem/niem-core/2.0"></IdentificationID>
</SendingMDELocationID>
<SendingMDEProfileCode xmlns="urn:oasis:names:tc:legalxml:schema:xsd:CommonTypes-4.0">urn:oasis:names:tc:legalxml:schema:xsd:WebServicesMessaging-2.0</SendingMDEProfileCode>
<ReviewCallbackMessage xmlns="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:ReviewFilingCallbackMessage-4.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<nc:DocumentFiledDate>
<nc:DateTime>2018-06-07T13:55:56.0Z</nc:DateTime>
</nc:DocumentFiledDate>
</ReviewCallbackMessage>
</NotifyCompleteRequestMessage>
</soapenv:Body>
</soapenv:Envelope>
This is the contract method and serializing class I'm using. In reality this should load the complete body into the attribute, but it's only loading the first node SendingMDELocationID. There has to be a way to load the complete xml body into one attribute without serializing the whole xml body since if I remove the SendingMDELocationID and SendingMDEProfileCode from the envelope it gives me exactly what I need which is the ReviewCallbackMessage node + all of it's descendants.
public NotifyCompleteResponse NotifyReviewComplete(NotifyCompleteRequest request)
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
public partial class NotifyCompleteRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:oasis:names:tc:legalxml:wsdl:WebServicesProfile-Definitions-4.0", Order = 0)]
public XElement NotifyFilingReviewCompleteRequestMessage;
public NotifyFilingReviewCompleteRequest()
{
}
}
Related
I am facing a problem with my webservice written in C#. It works fine until I want to call method with parameters, the SOAP Request generated from an external supplier using my wsdl looks like the following:
<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/">
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://127.0.0.1/AService</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">ANameSpace/login</Action>
</s:Header>
<soapenv:Body>
<ns1:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="ANameSpace">
<a_sDMSUserName xsi:type="xsd:string">test</a_sDMSUserName>
<a_sDMSUserPassword xsi:type="xsd:string">oscar</a_sDMSUserPassword>
</ns1:login>
</soapenv:Body>
</soapenv:Envelope>
This is a part of the interface of my Service:
[ServiceContract (Namespace ="ANameSpace")]
public interface IFordEcat
{
[OperationContract (Action ="ANameSpace/connect")]
int connect();
[OperationContract(Action = "ANameSpace/disconnect")]
int disconnect();
[OperationContract(Action = "ANameSpace/login")]
string login(string a_sDMSUserName, string a_sDMSUserPassword);
[OperationContract(Action = "ANameSpace/logout")]
string logout(string a_sSessionID, string a_sDMSUserName, string a_sDMSUserPassword);
With SoapUI or a test client setup in C# via Service Reference it works fine.
The only problem is that the parameters of the login Method or any other Method with parameters, are missing the namespace prefix (nsl) in the nodes where are the parameters are passed. When I add them manually for example in SOAPUi it works like charm. Is there a way to add the namespace prefix without inspecting every incoming request?
Many thanks in advance!
I am a bit unsure why you have to provide the Action attribute, because SOAP operations can work without it. Perhaps there lies the clue ...?
Alternatively, if you do wish to keep it and wish to add namespace for every request then you could explore XmlDocument class and XmlNode classes. A simple code snip is here which can add namespace at a specific node -
XmlDocument xdoc = new XmlDocument();
// Get Request Xml for each of the case
xdoc.LoadXml(xmlContent);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xdoc.NameTable);
nsmgr.AddNamespace("s", "http://schemas.xmlsoap.org/soap/envelope/");
nsmgr.AddNamespace("sc", "http://tempuri.org/");
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.
sirs, I have a case, when I
Make http request to rest resource
Get xml response
Understand what deserialized response is
I have generic method T Post(string uri, string body) that "knocking" to rest service and getting different responses on the same url and request format, for example
In one case I`m getting
<response>
<status>OK</status>
<statusCode>0</statusCode>
<result>Sample response message here</result>
</response>
In another case I`m getting
<response>
<status>OK</status>
<statusCode>0</statusCode>
<result>
<SampleEntityOne>Entity1 value</SampleEntityOne>
<SampleEntityTwo>Entity2 value</SampleEntityTwo>
...
<SampleEntityN>EntityN value</SampleEntityN>
</result>
</response>
So, how can I use something common when creating class that can be deserialized using XmlSerializer or DataContractSerializer?
Thanks
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 .
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, :)!