WCF - I have been given a SOAP request and I need to create a SOAP web service to consume this SOAP request - wcf

The sample SOAP request will come through like this:
<soapenv:Envelope xmlns:soapenv=http://www.w3.org/2003/05/soap-envelope>
<soapenv:Header xmlns:wsa=http://www.w3.org/2005/08/addressing>
<wsse:Security xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd soapenv:mustUnderstand="0">
<wsse:UsernameToken xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd wsu:Id="UsernameToken-1">
<wsse:Username>soapUserName</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
<wsa:To>https://wcfexample.com/Service.svc</wsa:To>
<wsa:MessageID>ABC123</wsa:MessageID>
<wsa:Action>SoapRQ</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ABC>
<DETAIL>
...
</DETAIL>
</ABC>
</soapenv:Body>
</soapenv:Envelope>
The Body of the soap envelope is xml, which I think would be best handled as a string and then I can serialise this once it hits the server.
I think the trickiest thing for me is setting up the configuration of WCF to handle the security portion of this.
Any help with this would be greatly appreciated.

The wcf setting security section usually selects the binding you want, then sets a security mode for the binding, and on the client side you can also set the client credential type. You can refer to the docs for more info.

Related

HttpWebRequest works with only asmx or wsdl also

HttpWebRequest works with only asmx or wsdl also ?
https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/Get26asInfo.wsdl
can b used ? with following data for - HttpWebRequest
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v="http://incometaxindiaefiling.gov.in/ditws/tds/v_1_0">
<soapenv:Header/>
<soapenv:Body>
<v:getTDSDetails>
<v:LoginInfo>
<v:userName>xxxxxxxxxx</v:userName>
<v:password>xxxxxxxxxx</v:password>
</v:LoginInfo>
<v:ClientInfo>
<v:pan>xxxxxxxxxx</v:pan>
<v:dob>xxxxxxxxxx</v:dob>
<v:assessmentYear>xxxxxxxxxx</v:assessmentYear>
</v:ClientInfo>
</v:getTDSDetails>
</soapenv:Body>
</soapenv:Envelope>
if not, how to get Response Envelope xml while consuming wsdl(service reference)
The WSDL exists as a framework to tell external entities how to consume the web service - you should send all actual web service requests to the ASMX file to ensure they are handled properly.
See the W3 specification

(vb.net) send a SOAP envelope

I consume a web service (available there) and I need to generate and to send a SOAP envelope, but it's not something i do understand.
I've found this example: http://macunsw.wordpress.com/2010/11/19/vb-net-example-for-calling-web-service-by-posting-soap-xml/
but still, i do not get it, the envelope i need to send is like that:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>cid:20100066603-01-F001-1.zip</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
Can someone help? thx
Since you're using VB.Net you're not required to handle the SOAP services on your own.
Add the WSDL path http://...?wsdl as a remote Service:
in the Solution Explorer rightclick your project
Choose Add Service Reference from the context menu
enter the path to WSDL in the Address field & Click Go
the billService should be found
choose a namespace, i.e. Sunat
From now on you can access the service as a simple object:
Dim billService As New Sunat.billServiceClient
billService.sendBill(fileName, contentFile)
billService.sendSummary(fileName, contentFile)
billService.getStatus(ticket)

How to solve the "cannot find soap action mapping for" soap api?

The request for soap api is given below
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:WashOut"
<soapenv:Header/>
<soapenv:Body>
<urn:Activate_VAS_Request soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<OPER_NAME xsi:type="xsd:string">?</OPER_NAME>
<OPER_PASSWORD xsi:type="xsd:string">?</OPER_PASSWORD>
<MSISDN xsi:type="xsd:string">?</MSISDN>
<VAS_ID xsi:type="xsd:int">?</VAS_ID>
<PARAM_VAL xsi:type="xsd:string">?</PARAM_VAL>
</urn:Activate_VAS_Request>
</soapenv:Body>
</soapenv:Envelope>
and the response of the request is given below.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode xsi:type="xsd:QName">Server</faultcode>
<faultstring xsi:type="xsd:string">Cannot find SOAP action mapping for</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
which thing causing the error.
This error means WashOut is unable to find the requested action (in your particular case it fails to even parse it – it's empty string).
Also the wash_out version you use is critically old. Current one is 0.9.0. Please upgrade.
I've seen that some Soap clients send the request in a way wash_out can't infer the soapAction value, as a consequence it can't link the request to an action in the wash_out controller.
For having a working reference, I think you should try a soap client such as soapUI or Savon, I've seen they send the request in a way wash_out can infer which is the soapAction in the request.

reading soap header element in payload

I need to read contents of wsse:Username(which is part of soap header) from following soap payload in mule using message-properties-transformer.
I would like to use this variable somewhere else.
Soap Webservice request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spel="http://mobistar.be/spellchecker/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" >
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>Tester01</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<spel:CheckSpellingRequest>
<spel:Text>Please test this blabla</spel:Text>
</spel:CheckSpellingRequest>
</soapenv:Body>
</soapenv:Envelope>
Please let me know if we can achieve this in mule?
Declare the "soapenv" and "wsse" namespaces in Mule's namespace manager: http://www.mulesoft.org/documentation/display/current/XML+Namespaces
Use XPath in a MEL expression to extract the value(s) you need: http://www.mulesoft.org/documentation/display/current/MEL+Cheat+Sheet#MELCheatSheet-XPathSupport
Also use set-variable, set-session-variable or set-property instead of the old message-properties-transformer.

SoapUI get response but not the .Net Client

I am trying to access a https Java webservice from .net client but always end up with "504 Gateway Timeout" exception.
I could get the response from the same webservice using SoapUI.
I also noticed that the request soap message of SoapUI and .net client aren't similar. My question is, does the wrong format of message gives the "504 Gateway Timeout" problem ? if yest, How could i modify the soap message in .net client?
Here are the request soap message that two different app generates:
SoapUI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://company.domain.com/EchoService/v1_00">
<soapenv:Header/>
<soapenv:Body>
<v1:Echo>test</v1:Echo>
</soapenv:Body>
</soapenv:Envelope>
.NET client
{<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">Echo</a:Action>
<a:MessageID>urn:uuid:7a76925d-5bf0-4f2d-a9c5-c5a026e1eefb</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Echo xmlns="http://company.domain.com/EchoService/v1_00">test</Echo>
</s:Body>
</s:Envelope>}
sorry, folks nothing to do with wcf binding or soap message but the proxy was blocking the request. SoapUI could send/receive the message because it doesn't use proxy. just changed useDefaultWebProxy="false" in binding section of configuration.