How to add the SOAP envelope and body for exchange object, while sending to the MQ with Apache Camel in Spring Boot App - soap

I wanna send message to the MQ with SOAP format but in exchange object i'll get only XML Data (without envelope,header and body), here i have to append the SOAP envelope and body to the exchange object as like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:act="http://ei/event/envprocess">
<soapenv:Header/>
<soapenv:Body>
**// exchange object get the xml data need to add here.**
</soapenv:Body>
</soapenv:Envelope>
for solution i found this link but i'm not getting how to get the cxf:cxfEndpoint object in spring boot and how to append payload or exchange data for it.
Can anyone please help me to resolve this issue.

As mentioned in the comment, you can use XSL to transform your message body into a SOAP request.
To call the XSL in the route is a one-liner:
.to("xslt:MyStylesheet.xsl?saxon=true")
This expects the MyStylesheet.xsl in the classpath root. If you want to leverage XSL 2, add the Saxon dependency and the option saxon=true.
If you only need XSL 1, you don't need Saxon and the option.
The solution you found would be to establish a SOAP communication through a JMS broker. In this scenario, MQ mimics a synchronous request/reply communication. This is a quite different subject than using standard MQ (asychronous sender and receiver).
If the simple XSL or SOAP over JMS better suits you case depends on the broader goal you want to reach.

Related

Log SOAP Envelop in message flow of Proxy in OSB

Is there a way to see te entire SOAP Envelop while developing a proxy message flow on OSB? I was thinking about using a Log action, but envelope is not a context variable. Is there a way to build it? Thx.
It is true that SOAP envelope is not a context variable when a SOAP message reaches Proxy.
You can rebuild the SOAP Envelope using following expression but change the namespace according to SOAP version. Assign it to a variable and log it after
For v1.2
<env:Envelope xmlns:env="https://www.w3.org/2003/05/soap-envelope">
<env:Header>
{$header/*}
</env:Header>
<env:Body>
{if ($fault) then ($fault) else ($body/*)}
</env:Body>
</env:Envelope>

Need configuration data for Mirth Web Service Sender

First time using Mirth. We will be communicating with an outside service. Part of the SOAP Envelope in the SOAP message is userId and passWord. In addition to that we need to basically perform a hash that creates a unique token each time we call the service. I need that part of the XML payload to come from a function. Is there a way for a piece of the data to be inserted into the SOAP Envelope that is the result of a JavaScript function call?
First of all you need to use the Web Service Sender Connector Type. In this example I have chosen an online weather web service.
Paste the WSLD URL (orange) and click the "Get Operations" button (red)
After selecting the correct service, click the "Generate Envelope" button (red) which will make a soap stub for you. Something like this, where you can use variables like this ${variableName}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
<web:GetCitiesByCountry>
<!--Optional:-->
<web:CountryName>${myGeneratedCountryName}</web:CountryName>
</web:GetCitiesByCountry>
</soapenv:Body>
</soapenv:Envelope>
For the variable to be populated with your calculated value you need to use, for instance, a javascript transformer.
Create a new Destination and edit the tranformer.
And then you can use javascript to calculate your value.
Last line is used to make the variable and its content available for the Web Service Sender. It works like a java Map
$co('myGeneratedCountryName',country);
However there are other methods, code templates for instance. If you are new to Mirth Connect I recommend you reading the Mirth Connect User Guide which covers this use case and many others.

How do I receive this code in php? And how do I consume it?

I'm working on a website project to consume a web service, how do I receive this in php and how do I consume it? Thank you for helping out. I need to connect to their API, send the XML file genrerated in my website and then receive the response. http://www.safaricom.co.ke/business/corporate/m-pesa-payments-services/m-pesa-api for the api
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c2b="http://cps.huawei.com/cpsinterface/c2bpayment">
<soapenv:Header/>
<soapenv:Body>
<c2b:C2BPaymentConfirmationRequest>
<TransactionType>PayBill</TransactionType>
<TransID>1234560000007031</TransID>
<TransTime>20140227082020</TransTime>
<TransAmount>123.00</TransAmount>
<BusinessShortCode>12345</BusinessShortCode>
<BillRefNumber>TX1001</BillRefNumber>
<InvoiceNumber></InvoiceNumber>
<OrgAccountBalance>12345.00</OrgAccountBalance>
<ThirdPartyTransID></ThirdPartyTransID>
<MSISDN>254722703614</MSISDN>
<KYCInfo>
<KYCName>[Personal Details][First Name]</KYCName>
<KYCValue>Hoiyor</KYCValue>
</KYCInfo>
<KYCInfo>
<KYCName>[Personal Details][Middle Name]</KYCName>
<KYCValue>G</KYCValue>
</KYCInfo>
<KYCInfo>
<KYCName>[Personal Details][Last Name]</KYCName>
<KYCValue>Chen</KYCValue>
</KYCInfo>
</c2b:C2BPaymentConfirmationRequest>
</soapenv:Body>
</soapenv:Envelope>
My best advice is to use a WSDL to php generator such as PackageGenerator as you'll only deal with object to send the request then only deal with object when getting back the response. Using the generated SDK really eases consuming any SOAP Web Service. It uses the native SoapClient class (which is the first real starting point in this case if you wish to understand deeply the process).
Safaricom has released M-Pesa APIs as RESTful APIs accessible through their developer portal . You need not use the M-Pesa SOAP APIs.

How to upload a attached file using Jmeter for SOAP

I need to upload a file(xml) using jmeter. I know how to do it for REST calls. But this is for SOAP request.
The request xml looks like,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://wsdl.api.doc.cdp.ipt.homeoffice.org/">
<soapenv:Header/>
<soapenv:Body>
<wsdl:createDocument>
<input>
<instanceId>999</instanceId>
<sessionId>999</sessionId>
<content>file:aaa.xml</content>
<mimetype>xml</mimetype>
</input>
</wsdl:createDocument>
</soapenv:Body>
</soapenv:Envelope>
Easy one: just record your call using JMeter's Proxy Server or Mobile Recorder service and replay it
Harder one: create POST request manually, switch HTTP Request sampler to "Body Data" mode and construct it there like:
See Insert MTOM Attachment for more details.
Hardest one: use JSR223 Sampler and Groovy language to generate request on-the-fly (it'll be required if your SOAP server is a little bit paranoid and expect security header with timestamps, expiration date, usernames tokens, etc.)
you can use web service soap request sampler to post it (check here) or you can try Http request sampler, please check here for handling it

Correct envelope to use for a SOAP request?

I'm trying to integrate with the SOAP API specified here:
https://api.okpay.com/OkPayAPI?singleWsdl
https://api.okpay.com/OkPayAPI?wsdl
At the moment the code autogenerated from the wsdl files appears to be acting up, so I'm wondering what should be the correct envelope to send and where should I be sending it?
I used this service for testing: http://www.soapclient.com/soapmsg.html . For server address I put in:
https://api.okpay.com/
And for SOAP Message I put in what my code is currently generating:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Get_Date_Time xmlns="https://api.okpay.com"></Get_Date_Time></Body></Envelope>
And the response appears to be a HTML code of a page, rather than an envelope response.
What would be the correct SOAP Action / Message to what Server Address to send in order to invoke the Get_Date_Time method as specified in the WSDL?
A couple of things:
The "Server Address" needs to point at the actual service, so in this case
https://api.okpay.com/OkPayAPI
The action can be seen in the WSDL, in this case
https://api.okpay.com/I_OkPayAPI/Get_Date_Time
Have a look at the WSDL and search for the action I gave above, that should give you an idea for how to find it for other actions.
With those two updates you should get back the response you expect:
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Get_Date_TimeResponse xmlns="https://api.okpay.com">
<Get_Date_TimeResult>2015-01-31 17:52:37</Get_Date_TimeResult>
</Get_Date_TimeResponse>
</s:Body>
</s:Envelope>