keep getting ERR.SWS.CLIENT.VALIDATION_FAILED exception when calling TravelItineraryReadRQ - c#

i am facing ERR.SWS.CLIENT.VALIDATION_FAILED exception in my code
my Request to Sabre
<?xml version="1.0" encoding="utf-16"?>
<TravelItineraryReadRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="3.9.0">
<MessagingDetails xmlns="http://services.sabre.com/res/tir/v3_10">
<SubjectAreas>
<SubjectArea>DEFAULT</SubjectArea>
</SubjectAreas>
</MessagingDetails>
<UniqueID ID="XXXXXX this is changed" xmlns="http://services.sabre.com/res/tir/v3_10" />
<ReturnOptions xmlns="http://services.sabre.com/res/tir/v3_10" />
</TravelItineraryReadRQ>
Kindly Help me in this exception

The one below works for me:
<TravelItineraryReadRQ Version="3.9.0" TimeStamp="2012-09-19T10:00:00-06:00"
xmlns="http://webservices.sabre.com/sabreXML/2011/10">
<MessagingDetails>
<SubjectAreas>
<SubjectArea>FULL</SubjectArea>
</SubjectAreas>
</MessagingDetails>
<UniqueID ID="XXXXXX"/>
<ReturnOptions UnmaskCreditCard="false"/>
</TravelItineraryReadRQ>
Did you also set the headers correctly?

Related

How to send request to a method of Web Service from Postman?

I have an ASMX service, which has the below method. I want to debug this method, so I have put a breakpoint on it. But I am not able to send a request to it successfully, It gives a 404 error.
[WebMethod]
public void RequestNotification()
{
I have tried these options so far.
Page screenshots for reference.
This is how I am calling from the C# code, and this is also not hitting the breakpoint on the method RequestNotification of service. and it's not giving any exceptions also in the C# code.
MyService myService= new MyService ();
myService.RequestNotification();
Update: I have tried as described in the below answer, I am still getting 404.
Please find below the request screenshot.
Using POST call from Postman with XML Body
Demo code.
I will show this Calculator SOAP service for Add operation.
POST URL
http://www.dneonline.com/calculator.asmx
In body with XML ray selection
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<intA>100</intA>
<intB>200</intB>
</Add>
</soap:Body>
</soap:Envelope>
I got response this from service
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>300</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
If you click code button from Postman, you can get the curl command too.
curl --location --request POST 'http://www.dneonline.com/calculator.asmx' \
--header 'Content-Type: text/xml; charset=utf-8' \
--header 'SOAPAction: http://tempuri.org/Add' \
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<intA>100</intA>
<intB>200</intB>
</Add>
</soap:Body>
</soap:Envelope>
'
#Bench Vue's answer has helped me in solving the issue. I am able to solve the issue with the below request.
Request and Response:

c# send SOAP request with headers

I need to send an custom header mentioned below and get response from the proxy client. could some please share some basic sample code to achive the same.
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3">
<soap:Header>
<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">0685482c-7f32-46b6-b27f-3149935b9307</add:MessageID>
<add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/Hotel_MultiSingleAvailability_10.0</add:Action>
<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://noded5.test.webservices.amadeus.com/1ASIWPOC1A</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 xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" oas1:Id="UsernameToken-1">
<oas:Username></oas:Username>
<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">RjJmUSsjczI=</oas:Nonce>
<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">ZmJhZTdhY2E0YzdkYjIyODFkNDY2Y2RjZDYxN2MyZDlkYTE5NWJkYg==</oas:Password>
<oas1:Created>2022-09-08T18:27:59.86Z</oas1:Created>
</oas:UsernameToken>
</oas:Security>
<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">
<UserID AgentDutyCode="SU" POS_Type="1" PseudoCityCode="" RequestorType="U" />
</AMA_SecurityHostedUser>
</soap:Header>
</soap:Envelope>

Custom fault type for an ASP.NET webservice

I am developing a webservice in C#, ASP.NET. By default, when my webservice throws exception, using
throw new SoapException("ERROR_MESSAGE", SoapException.ClientFaultCode);
This outputs the following xml:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>ERROR_MESSAGE</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
However, I have to implement a custom fault type that uses different xml:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:cst="http://cust.om/Namespace">
<cst:Fault>
<cst:errorMessage>ERROR_MESSAGE</cst:errorMessage>
</cst:Fault>
</soap:Body>
</soap:Envelope>
They expect that this fault type appears also in the wsdl file that is generated by http-GETting ?wsdl, surfacing there as element.
Is this even possible? Well, everything is possible by rewriting the exiting stream with replaced string, but I'd prefer less brutal approach. Besides, that kind of fix would not cause the elements to appear in the auto-generated wsdl spec.

doc.LoadXml giving error data at the root level is invalid

I am having xml response like below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CreateMeetMeOrWebMeetingResults
xmlns:ns2="coss-ws-common">
<transactionId>z8kflt5fi2x28vd51</transactionId>
<status>OK</status>
<meetme id="178635601">
<billingCode>MR5942965</billingCode>
<confirmationId>Q-1GFR347H6I</confirmationId>
<serviceId>1021</serviceId>
<serviceName>BT MeetMe</serviceName>
<timezone>America/New_York</timezone>
<topic>Danny Chung</topic>
<chairpasscode>34132738</chairpasscode>
<participantpasscode>84781442</participantpasscode>
<dialInNumber>
<phoneType>PSTN</phoneType>
<formattedNumber>0203 463 9676</formattedNumber>
<displayName>Direct: 0203 463 9676</displayName>
<rawNumber>02034639676</rawNumber>
</dialInNumber>
<createDate>2014-11-25T09:34:33.168Z</createDate>
<createdByApplicationId>1120</createdByApplicationId>
<bridgeId>892</bridgeId>
<recurringFlag>false</recurringFlag>
<globalAccessFeature locked="false" enabled="true">
<url>Please contact help desk</url>
</globalAccessFeature>
<meetingType>MEETME</meetingType>
<serviceType>MEETME</serviceType>
<pendingBlackoutDateApproval>false</pendingBlackoutDateApproval>
<chairpersonRecord locked="false" enabled="true"/>
</meetme>
</CreateMeetMeOrWebMeetingResults>
I am trying to convert it into xml by doc.LoadXml(response) and its giving error for invalid data at root level.
if somebody can help to solve the issue
If that is your complete xml, you missed a closing tag:
</CreateMeetMeOrWebMeetingResults>
Try adding it at the bottom of your xml
Looking at your indentation, could be that your xml starts with a whitespace. This could be another reason
You don't seem to have a root element for your xml. This works for me.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<CreateMeetMeOrWebMeetingResults xmlns:ns2="coss-ws-common"/>
<transactionId>z8kflt5fi2x28vd51</transactionId>
<status>OK</status>
<meetme id="178635601">
<billingCode>MR5942965</billingCode>
<confirmationId>Q-1GFR347H6I</confirmationId>
<serviceId>1021</serviceId>
<serviceName>BT MeetMe</serviceName>
<timezone>America/New_York</timezone>
<topic>Danny Chung</topic>
<chairpasscode>34132738</chairpasscode>
<participantpasscode>84781442</participantpasscode>
<dialInNumber>
<phoneType>PSTN</phoneType>
<formattedNumber>0203 463 9676</formattedNumber>
<displayName>Direct: 0203 463 9676</displayName>
<rawNumber>02034639676</rawNumber>
</dialInNumber>
<createDate>2014-11-25T09:34:33.168Z</createDate>
<createdByApplicationId>1120</createdByApplicationId>
<bridgeId>892</bridgeId>
<recurringFlag>false</recurringFlag>
<globalAccessFeature locked="false" enabled="true">
<url>Please contact help desk</url>
</globalAccessFeature>
<meetingType>MEETME</meetingType>
<serviceType>MEETME</serviceType>
<pendingBlackoutDateApproval>false</pendingBlackoutDateApproval>
<chairpersonRecord locked="false" enabled="true"/>
</meetme>
</root>

C# XPath Soap, how to navigate to embedded node

In C#, Asp.Net, I am trying to return the Error node inside of BISearchResponse:
I am able to get the GetWireResult node returned in an XMLNode.
How do I get to the Error node?
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <GetWireResponse xmlns="http://OpenSolutions.com/">
<GetWireResult><?xml version="1.0"?>
<BISearchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Error xmlns="https://bixg.choicepoint.com/webservices/3.0">
<Message>BI System: Failed to Login</Message>
<Code>536870917</Code>
</Error>
</BISearchResponse>
</GetWireResult>
</GetWireResponse>
</soap:Body>
</soap:Envelope>
My code:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
nsmgr.AddNamespace("ab", "http://OpenSolutions.com/");
nsmgr.AddNamespace("bg", " https://bixg.choicepoint.com/webservices/3.0");
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
XmlNode xmlnode = xmlDoc.DocumentElement.SelectSingleNode("/soap:Envelope/soap:Body/ab:GetWireResponse", nsmgr);
This works to here.
.
I am adding the xml here, but it is only visible in edit mode.
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <GetWireResponse xmlns="http://OpenSolutions.com/">
<GetWireResult><?xml version="1.0"?> <BISearchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Error xmlns="https://bixg.choicepoint.com/webservices/3.0"> <Message>BI System: Failed to Login</Message> <Code>536870917</Code> </Error> </BISearchResponse></GetWireResult>
</GetWireResponse>
</soap:Body>
</soap:Envelope>
In debug mode, when you copy this XML, try choose another debug visualizer, e.g. "Text visualizer". You can select it clicking the magnifying glass icon in datatip.
I think your XML looks like:
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetWireResponse xmlns="http://OpenSolutions.com/">
<GetWireResult>
<?xml version="1.0"?>
<BISearchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Error xmlns="https://bixg.choicepoint.com/webservices/3.0">
<Message>BI System: Failed to Login</Message>
<Code>536870917</Code>
</Error>
</BISearchResponse>
</GetWireResult>
</GetWireResponse>
</soap:Body>
</soap:Envelope>
or
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetWireResponse xmlns="http://OpenSolutions.com/">
<GetWireResult>
<![CDATA[
<?xml version="1.0"?>
<BISearchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Error xmlns="https://bixg.choicepoint.com/webservices/3.0">
<Message>BI System: Failed to Login</Message>
<Code>536870917</Code>
</Error>
</BISearchResponse>
]]>
</GetWireResult>
</GetWireResponse>
</soap:Body>
</soap:Envelope>
No matter. So you can select GetWireResult using following XPath:
/soap:Envelope/soap:Body/ab:GetWireResponse/ab:GetWireResult
and then load it content in new XML document and get desired response.
You're almost there. Extend your XPath
"/soap:Envelope/soap:Body/ab:GetWireResponse"
to
"/soap:Envelope/soap:Body/ab:GetWireResponse/ab:GetWireResult/ab:BISearchResponse/bg:Error"
However that extra XML prologue stuck in there in the middle, <?xml version="1.0"?>, makes the XML not well-formed. I'm surprised it can be processed at all. I would think the C# API should throw an exception on xmlDoc.LoadXml(result).
Another approach, seeing as the above does not return anything for you, would be to use your C# code to explore the structure of the XML document and print out the children of each node. E.g. if you are getting a node for "/soap:Envelope/soap:Body/ab:GetWireResponse" but not for "/soap:Envelope/soap:Body/ab:GetWireResponse/ab:GetWireResult", does ab:GetWireResponse have what text node children, and if so, what are their values (contents)? That should give insight into why the XPath is not working.
If there's a block of unparsed (i.e. escaped) XML in there, you could either copy it out and parse it as XML like you said, or just search for the pattern you need using a regexp... depending on the complexity.

Categories

Resources