reading soap header element in payload - mule

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.

Related

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

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.

WCF binding configuration for SalesForce Api

For an application i'm developing i need to make a call on the SalesForce api. With SvcUtil i generated a proxy and integrated this in my solution. After i made a call via code, i get the following request and exception response. I use a normal basicHttpBinding.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"></Action>
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink"></VsDebuggerCausalityData>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<login xmlns="urn:partner.soap.sforce.com">
<username>XXX</username>
<password>XXX</password>
</login>
</s:Body>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns="">soapenv:Client</faultcode>
<faultstring xmlns="">No operation available for request {urn:partner.soap.sforce.com}login</faultstring>
</soapenv:Fault>
</soapenv:Body>
However, if call the service with SoapUI, i don't get any errors. After googling i tried to make some changes in the binding and created a custom binding for forcing the soap version to 1.2, but didn't find a good solution. What should i change in the binding configuration?
This is the SoapUI call:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
<soapenv:Body>
<urn:login>
<urn:username>XXXX</urn:username>
<urn:password>XXXX</urn:password>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
After some research i found out that creating a proxy using "Add service reference" creates a proxy that works. So my problem is solved. Still have to check what the difference is between the generated proxies.

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

how to move xmlns to envelope WCF

I have a WCF Web Service, this must accept a request from a other non .net client, my problem is that WCF is especting the soap like this:
<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>
<myMethod xmlns="http://webservices.myServices/">
<param1>ABC</param1>
<param2>123</param2>
</myMethod>
</soapenv:Body>
</soapenv:Envelope>
but the client is sending
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://webservices.myServices/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:myMethod>
<param1>ABC</param1>
<param2>123</param2>
</q0:myMethod>
</soapenv:Body>
</soapenv:Envelope>
The only difference is that xmlnamespace is inside the Envelope tag, but for some reason WCF dont understand it.