I have a problem getting a client to integrate with my system. I think I have narrowed the problem. The client is sending over an xml message and my system is setup to accept an xml message; however it is expecting it in certain format. The client has expressed a desire for me to setup the format on my end to accept theirs.
This is the clients message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<NewOrder>
<Message id="d3a39c31-cc9f-4331-ad13-be74522df6eb">
<Header>
<LoginAccountIdentifier>Blank</LoginAccountIdentifier>
<LoginAccountPassword>password</LoginAccountPassword>
</Header>
I noticed that my expected format is excepting the prefix tem: on the nodes.
This is expected message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:NewOrder>
<tem:Message id="d3a39c31-cc9f-4331-ad13-be74522df6eb ">
<Header>
<LoginAccountIdentifier>Blank</LoginAccountIdentifier>
<LoginAccountPassword>password</LoginAccountPassword>
</Header>
I believe that if I can remove the prefix then this should match up the client's message with expected message. The problem is where do I remove the prefix "< tem:"; furthermore, how do I prevent this variable xmlns:tem="http://tempuri.org/" from showing up in my document?
I ran into a similar issue too long ago. Try using this:
[ServiceContract(Namespace = "")]
Apparently, the prefix is determined by the namespace so if you want it removed then this would be the way to go.
Good luck!
I'm pretty sure that's from the WebService.svc (or .asmx) class having a
[WebService(Namespace = "http://tempuri.org/")]
attribute at the top of the class definition. Removing this (or setting it to an appropriate value) should remedy the problem.
Related
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()
{
}
}
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/");
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.
While trying to invoking my Amadeus Fare_masterpricetravelboard Service using SoapUI like mozila poster, Google restclient app, or my .net code, it returns the following error message:
A header representing a Message Addressing Property is not valid and the message cannot be processed
The same webservice is working fine in SOAP UI Tool.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://xml.amadeus.com/2010/06/Security_v1" xmlns:typ="http://xml.amadeus.com/2010/06/Types_v1" xmlns:iat="http://www.iata.org/IATA/2007/00/IATA2010.1" xmlns:app="http://xml.amadeus.com/2010/06/AppMdw_CommonTypes_v3" xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3" xmlns:fmp="http://xml.amadeus.com/FMPTBQ_10_3_1A">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">65449120-2aa0-46b0-9dcc-c40c6439836c</add:MessageID>
<wsa:Action>http://webservices.amadeus.com/FMPTBQ_10_3_1A</wsa:Action>
<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://nodeD1.test.webservices.amadeus.com/1ASIWIBEWWZ</add:To>
<link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" />
<oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<oas:UsernameToken oas1:Id="UsernameToken-1" xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<oas:Username>WSWWZIBE</oas:Username>
<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">EoCeDbDbThB=</oas:Nonce>
<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">Hr2HRG8j0dTH19kh52wQ5aqMxhU=</oas:Password>
<oas1:Created>2014-07-19T12:33:47:530Z</oas1:Created>
</oas:UsernameToken>
</oas:Security>
<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">
<UserID POS_Type="1" PseudoCityCode="THRI4213V" RequestorType="U" />
</AMA_SecurityHostedUser>
</soapenv:Header>
<soapenv:Body>
<Fare_MasterPricerTravelBoardSearch>
<numberOfUnit>
<unitNumberDetail>
<numberOfUnits>1</numberOfUnits>
<typeOfUnit>PX</typeOfUnit>
</unitNumberDetail>
<unitNumberDetail>
<numberOfUnits>250</numberOfUnits>
<typeOfUnit>RC</typeOfUnit>
</unitNumberDetail>
</numberOfUnit>
<paxReference>
<ptc>ADT</ptc>
<traveller>
<ref>1</ref>
</traveller>
</paxReference>
<fareOptions>
<pricingTickInfo>
<pricingTicketing>
<priceType>RP</priceType>
<priceType>RU</priceType>
<priceType>TAC</priceType>
</pricingTicketing>
</pricingTickInfo>
</fareOptions>
<itinerary>
<requestedSegmentRef>
<segRef>1</segRef>
</requestedSegmentRef>
<departureLocalization>
<departurePoint>
<locationId>CDG</locationId>
</departurePoint>
</departureLocalization>
<arrivalLocalization>
<arrivalPointDetails>
<locationId>LHR</locationId>
</arrivalPointDetails>
</arrivalLocalization>
<timeDetails>
<firstDateTimeDetail>
<timeQualifier>TA</timeQualifier>
<date>041114</date>
<time>2200</time>
<timeWindow>4</timeWindow>
</firstDateTimeDetail>
<rangeOfDate>
<rangeQualifier>C</rangeQualifier>
<dayInterval>1</dayInterval>
</rangeOfDate>
</timeDetails>
</itinerary>
</Fare_MasterPricerTravelBoardSearch>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soap:Envelope>
<soap:Header>
<wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action>
<wsa:MessageID>urn:uuid:0ce4ebc0-7753-6394-4945-c7e8f81c2c49</wsa:MessageID>
<wsa:RelatesTo RelationshipType="http://www.w3.org/2005/08/addressing/reply">65449120-2aa0-46b0-9dcc-c40c6439836c</wsa:RelatesTo>
<wsa:FaultDetail>
<wsa:ProblemHeaderQName>wsa:To</wsa:ProblemHeaderQName>
<wsa:ProblemIRI>https://nodeD1.test.webservices.amadeus.com/1ASIWIBEWWZ</wsa:ProblemIRI>
</wsa:FaultDetail>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>wsa:InvalidAddressingHeader</faultcode>
<faultstring>A header representing a Message Addressing Property is not valid and the message cannot be processed</faultstring>
<faultactor>SI:muxDZ1</faultactor>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Be sure that the url of the web request matches the value of the tag "add:To", including letter case.
Probably you are developing in .net and, even if you set the url in the same letter case, the request will be sent to the address in lowercase. So nodeD1 become noded1 in http layer but remains nodeD1 in soap envelope. Be careful to use lowercase or uppercase in both fields
This could be because of SOAPAction as well.
In my case ,
Soap UI internally uses : http://webservices.amadeus.com/{{orgCode}}/FMPTBQ_21_4_1A
when generating stub, orgCode is missed it came as http://webservices.amadeus.com/FMPTBQ_21_4_1A
After changing SoapAction explicitly in the code, started working.
I have created a solution.
Added the WSDL file.
This keeps on popping following error "Length Required".
I tried with the above code in the post (, but seems that is not working.
Where do we specify the Operation name here?
-- Anand
Before getting it to work in java c# .net etc you need to get the SOAP xml correct.
The operation name is added as a tag in the soap body element.
Say for example your operation name is createMyOTRSTicket as specified in OTRS UI Web Service.
The SOAP request sent should look something like this like this:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<createMyOTRSTicket xmlns="WS">
<UserLogin>MyUserName</UserLogin>
<Password>MyPassword</Password>
<Queue>'some queue name'</Queue>
<State>'some state name'</State>
<Priority>1</Priority>
<!-- ...etc.. -->
<Article>
<Subject>some subject</Subject>
<Body>some body</Body>
<ContentType>text/plain; charset=utf8</ContentType>
</Article>
</createMyOTRSTicket >
</soap:Body>
</soap:Envelope>
See the API for what elements are require and which are optional for TicketCreate here
The Soap Message should be sent to /nph-genericinterface.pl/Webservice/CreateTicketWS where CreateTicketWS is the name of the Web Service.
Also note that the attribute xmlns="WS" refers to the Namespace you specify in "Network Transport" config also locatred in the GenericInterface Web Service Management.
I hope this helps you. Sorry it might be a bit confusing for someone new to SOAP and OTRS.