How do I remove method name in SOAP? - c#

I need to remove the <tem:testApi> tag from the provided code, I have tried OperationContract, MessageContract, DataContract, and XmlSerilizer Contract but none of them are working.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:testApi> <--(I want to remove this tag )
<!--Optional:-->
<tem:Request>
<!--Optional:-->
<tem:Header>

Related

How to read, alter, and update back the item values inside <soapenv: Body> tag in AfterReceiveRequest() method

I am now implementing AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) method of IDispatchMessageInspector interface to intercet the WCF SOAP message.
System.ServiceModel.Channels.Message request as below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<To soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:8993/TLS.svc/soap</To>
<Action soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/TLS/GetMerchant</Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>value1</tem:item1>
<tem:item2>value2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
I would like to read and alter the value of <tem:item1></tem:item1> <tem:item2></tem:item2> and update back to System.ServiceModel.Channels.Message request without damaging other message original properties
<soapenv:Envelope ... >
<soapenv:Header>
<To soapenv:mustUnderstand="1" ... </To>
<Action soapenv:mustUnderstand="1" ... </Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>Updatedvalue1</tem:item1>
<tem:item2>Updatedvalue2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
This post describes the way you can handle it at Dispatcher level, which will allow you to intercept all incoming messages. You just need to understand and read it carefully.
https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector

How to get xmlnodelist of OriginDestinationOptions which is having exact two OriginDestinationOption

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).

Security Certificate on Webservices

I have a webservice from a partner that am developing against in C#. I have browsed it on SOAPUI and this is the request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ser="http://service.bank.pmt.tpa" xmlns:xsd="http://bean.bank.pmt.tpa/xsd">
<soapenv:Header/>
<soapenv:Body>
<ser:processPaymentNotificationReport>
<!--Zero or more repetitions:-->
<ser:pmtNotifyReport>
<!--Optional:-->
<xsd:amountPaid>?</xsd:amountPaid>
<!--Optional:-->
<xsd:bankBranchCode>?</xsd:bankBranchCode>
<!--Optional:-->
<xsd:bankTransNo>?</xsd:bankTransNo>
<!--Optional:-->
<xsd:datePaid>?</xsd:datePaid>
<!--Optional:-->
<xsd:paymentRegTransNo>?</xsd:paymentRegTransNo>
<!--Optional:-->
<xsd:status>?</xsd:status>
<!--Optional:-->
<xsd:taxPayerName>?</xsd:taxPayerName>
<!--Optional:-->
<xsd:tin>?</xsd:tin>
<!--Optional:-->
<xsd:transactionId>?</xsd:transactionId>
</ser:pmtNotifyReport>
</ser:processPaymentNotificationReport>
when i input the parameters and browse, this is the response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>wsse:InvalidSecurity</faultcode>
<faultstring>Missing wsse:Security header in request</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I have reconstructed the request xml in my code then send the xml to the partner by invoking their url. Now i find out that i cannot hit their webservice until i implement the security certificate. I have no idea how i can import that security certificate and use it in my code, need some help pease.

Parsing Soap Response in VB.net

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.

SOAP call with multiple namespaces

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?

Categories