How to upload a attached file using Jmeter for SOAP - 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

Related

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

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.

Using Insomnia To Make Soap Calls

I am trying to use Insomnia to make soap calls - specifically trying to get post to succeed. I defined the URL as the end point and put the body type as XML with the SOAP contents (envelope, header, body). I defined the user id and password in the header. When I run I get 415 Unsupported Media Type. I can't really paste the soap contents because of all of the URL addressing in the envelope. I am using Insomnia to succeed in doing the REST call to get my information (for some crazy reason the gets are REST but the posts are SOAP) but can't get the insert to work. Is there something special I need, or does Insomnia not support SOAP post transactions? I googled and it appears in 2018 this was added. I don't have the WSDL available.
I appreciate this is not giving lots of information so guidance on what more I may provide to get assistance will also be helpful. Has anyone succeeded in using Insomnia to make SOAP calls?
All that was needed for me to make it work was:
Request method: POST.
Setting the Content-Type header to text/xml; charset=utf-8 (application/xml gave me the 415 response).
Wrapping request body in proper SOAP envelope.
You should be able to call GET on YourHandler.asmx to look up envelopes for requests you want to use. Envelope should look somewhat like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/">
<foo>
<Id>1</Id>
<Name>Bar</Name>
</foo>
</HelloWorld>
</soap:Body>
</soap:Envelope>
Credits for the guidance and envelope sample goes to this answer.
You can import the WSDL file, so that all methods, headers etc. will be created automatically. Click on:
Go to dashboard
Click Create
Choose URL (under import from)
Paste the WSDL URL and click Fetch and Import
As an example you can use the following URL: http://www.dneonline.com/calculator.asmx?wsdl
You will get this:
The problem as of writing this answer is, that there are two bugs:
Not all WSDL URLs are getting imported correctly (e.g. this one works in SOAP UI, but not in Insomnia http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL)
The methods are getting imported, but they don't work
You can submit and issue on Github, so that this is getting fixed: https://github.com/Kong/insomnia

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 does Dart leverage SOAP requests?

I was looking up how to do SOAP requests within Dart. When looking at HTTPRequest it really only mentions RESTful services and wanted to make sure that this can be done.
Right now, I have my server, username, and password. Trying to get a successful authentication via the service, so that way I have an auth token i can pass when doing subsequent calls.
It seems for example in .NET, it does the following and then stores the credential in a server side session variable which I was using as a starting point to make this in Dart.
// create web service api object
WebServiceAPI api = new WebServiceAPI();
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["ProxyUserName"]))
{
System.Net.NetworkCredential nc = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["ProxyUserName"], ConfigurationManager.AppSettings["ProxyPassword"], ConfigurationManager.AppSettings["ProxyDomain"]);
System.Net.CredentialCache cc = new System.Net.CredentialCache();
cc.Add(new Uri(api.Url), "NTLM", nc);
api.Credentials = cc;
}
api.AuthenticateCredential("api#admin", "admin", 0, 0);
HttpContext.Current.Session["api"] = api;
Edit: I am adding some sample data such that if there is a hack we can leverage to get something working, we might be able to abstract it and genericize.
service asmx file:
http://127.0.0.1:1337/service.asmx
Method we will be calling: (AuthenticateCredential)
http://127.0.0.1:1337/service.asmx?op=AuthenticateCredential
The sample SOAP request:
POST /service.asmx HTTP/1.1
Host: 127.0.0.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://foo.com/bar/320/Default/AuthenticateCredential"
<?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>
<AuthenticateCredential xmlns="http://foo.com/barr/320/Default">
<UserName>string</UserName>
<Password>string</Password>
<CurrentSystemLoginID>int</CurrentSystemLoginID>
<CurrentCustomerID>int</CurrentCustomerID>
</AuthenticateCredential>
</soap:Body>
</soap:Envelope>
then naturally, I will have to write up and mod the string,string,int,int out of the envelope. such that the credentials are correct.
I've performed SOAP actions for Blackboard's web services using Dart, so it's possible. To do so, I had to build the SOAP envelope programmatically for each request. The requests themselves were sent using the http package's 'post' method.
Can't say how your requests should be set up, that would depend on the web service you're attempting to access. For the HTTP headers, I sent a 'Content-Type' of 'text/xml; charset=utf-8' and a 'SOAPAction' header specifying the SOAP method. The body was the full SOAP envelope.
You may need to play around a bit to build the envelope with the correct format/info your service expects. I used the xml package to parse/interpret the responses.
AFAIK there is no solution for that. There are only limited XML packages for Dart and I haven't seen attempts to implement SOAP itself.
A possible workaround would be to delegate to a server written in another language that forwards REST calls as SOAP calls.

Using JMeter SOAP/XML-RPC Request to call ChemSpell Web Service

I'm trying to test the web service api for a free service called ChemSpell. I am trying to use JMeter's SOAP/XML-RPC Request option to test it. I am a bit new at this and not sure what to enter in. The call expects two parameters, which for testing purposes I want to set to the following:
Name = "formeldehyde"
Source = "All databases"
Based on their site I'm putting "http://chemspell.nlm.nih.gov:80/axis/SpellAid.jws" for the URL and "http://chemspell.nlm.nih.gov" in Send SOAPAction. I'm not sure how to configure the "Soap/XML-RPC Data" portion. I'm thinking the WSDL file they provide should give me everything I need to configure that section, but I'm not exactly sure how. Any help is much appreciated!
You need to create the xml that will be sent to the webservice, based on the wsdl, and paste it in the SOAP/XML-RPC data field.
The xml will describe the method call you wish to make and the data you wish to pass to it.
It will look like this (you will need to replace ? with data):
<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:spel="http://chemspell.nlm.nih.gov/axis/SpellAid.jws/axis/SpellAid.jws">
<soapenv:Header/>
<soapenv:Body>
<spel:getSugList soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<name xsi:type="xsd:string">?</name>
<src xsi:type="xsd:string">?</src>
</spel:getSugList>
</soapenv:Body>
</soapenv:Envelope>
The easiest way to generate blank requests like the above is using SOAP UI. You just give the wsdl URL and it generates all possible requests for you. I copy and paste these over to JMeter.