I have below Soap response XML string
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header />
<soapenv:Body>
<qu:quotationResponse xmlns:qu="http://Reliance_RENEWAL_Quotation/IRenewal_Quotation">
<response><?xml version="1.0" encoding="UTF-8"?>
<RENEWAL-QUOTATION-RESPONSE>
<MESSAGE-DATA>
<ContractType>XYZ </ContractType>
<PremiumAmount>10000</PremiumAmount>
<PremiumSuspense>0.0</PremiumSuspense>
<NetAmmount>10000.0</NetAmmount>
<ContractPremiumStatus>Surrender </ContractPremiumStatus>
<ContractOwnerClientNumber>0501234</ContractOwnerClientNumber>
<OwnerName>SUDZ</OwnerName>
<LifeAssuredClientNumber>12312312</LifeAssuredClientNumber>
<LifeAssuredName>SUDZ </LifeAssuredName>
<PaidTodate>20110731</PaidTodate>
<ReinstatementFee>0.0</ReinstatementFee>
<ContractNumber>1122112211</ContractNumber>
</MESSAGE-DATA>
<ERROR-DETAILS>
<ErrorCode>No Errors</ErrorCode>
<ErrorDesc></ErrorDesc>
</ERROR-DETAILS>
</RENEWAL-QUOTATION-RESPONSE>
</response>
</qu:quotationResponse>
</soapenv:Body>
</soapenv:Envelope>
I need the value of ContractType, NetAmount etc
I tried but not able to parse.
What is best the way to parse above xml.
Please help.
Related
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 can send the Basic Authentication request within the xml itself without even writing something like
request.headers.add("");
and adding like this
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Authentication xmlns="http://tempuri.org/">
<Password>string</Password>
<UserName>string</UserName>
</Authentication>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Similarly I want to set the SOAPAction within the header xml itself instead of writing
request.headers.add("SOAPAction","someAction");
Somewhat like this
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<SOAPAction>http://abc/xyz/test</SOAPAction>
<Authentication xmlns="http://tempuri.org/">
<Password>string</Password>
<UserName>string</UserName>
</Authentication>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Please guide me that How it can be achieved?
How to get xmlnodelist of OriginDestinationOptions which is having exact two OriginDestinationOption.
<?xml version="1.0" encoding="utf-8"?>
<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">
<soapenv:Body>
<OTA_AirPriceRS xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<ns1:PricedItinerary ApplyMarkup="Y" FareType="Refundable" LFSPRICEDIFF="0" MatrixFare="" OriginDestinationRPH="DELBOMG8346G820160520BOMDELG8329G820160522" OriginDestinationRefNumber="2" ReturnOnly="true" SequenceNumber="" SupplierSystem="G8CP" isTBF="false">
<ns1:AirItinerary FareType="Refundable" SupplierCode="G8CP" SupplierSystem="G8CP" TripType="" UniqueIdentifier="1">
<ns1:OriginDestinationOptions WorkFlow="PFB">
<ns1:OriginDestinationOption>
</ns1:OriginDestinationOption>
<ns1:OriginDestinationOption>
</ns1:OriginDestinationOption>
</ns1:AirItinerary>
</OTA_AirPriceRS>
</soapenv:Body>
</soapenv:Envelope>
The XPath would be as follow :
//ns1:OriginDestinationOptions[count(ns1:OriginDestinationOption)=2]
Make sure to register the prefix ns1 to an XmlNamespaceManager and don't forget to pass the namespace manager to SelectNodes() or SelectSingleNode() (whichever you use to execute the XPath).
Is it possible to remove the what appears to be automatic notificationRequestResponse node from the response?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationRequestResponse xmlns="...">
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</notificationRequestResponse>
</soap:Body>
</soap:Envelope>
I need to return the below:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</soap:Body>
</soap:Envelope>
I want the notificationResponse to be the root of the response!
The WebMethod currently has no logic but:
return new notificationResponse()
Where is the notificationRequestResponse coming from? I can rename it using WebMethod SoapDocumentMethod(ResponseElementName="new name") but I want it gone. Working to a provided spec and have no choice.
Appreciated.
Found the answer...
SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)
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?