Using Insomnia To Make Soap Calls - soap

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

Related

Why do i get "Wrong API base URL used" when pinging Adobe EchoSign Cloud by a SOAP request?

I am trying to access signed documents within the Adobe EchoSign Cloud. I have got an API key for authentication and used it in a testPing SOAP request like
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:api="http://api.echosign">
<soapenv:Header/>
<soapenv:Body>
<api:testPing>
<api:apiKey>myKeyhere</api:apiKey>
</api:testPing>
</soapenv:Body>
</soapenv:Envelope>
I sent this request to
https://secure.echosign.com/services/EchoSignDocumentService22
But as a result I only get
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Wrong API base URL used</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What does that message mean?
I suspect Cross-Domain but you should test it with fiddler. It reports you more clean data with your problem.
I found an important note in the Adobe documentation:
However, starting from version 22 of the Document API, all API calls must be made on a specific base URL obtained either using the OAuth workflow (the api_access_point parameter that is included with an authorization code) or by making a call to the getBaseUris method. The corresponding gateway can then be constructed by concatenating the base URL with "services/EchoSignDocumentService22". Calls made on the wrong base URL will result in an exception indicating that the wrong API base URL was used. Note that getBaseUris itself can be called on any appropriate gateway, including the one mentioned above.
Calling getBaseUris indeed returns another URI which then can be used for subsequent requests.

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.

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>

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.

Unable to create(POST) objects (Account, customer...) on QB Windows using IDS and Sync Manager

Here I am provideing you the complete scenario where I am getting the error while posting request for creating a new account.
I am using Intuit OAuth Access and OAuth API console for testing (Using all security tokens).(https://appcenter.intuit.com/Playground/OAuth)
And the URL and request:
URL: https://services.intuit.com/sb/account/v2/570357960
Method : Post
Format: XML/JSON
Request:
<?xml version="1.0" encoding="UTF-16"?><Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="4df87bw2-916a-
4r95-h5d6-06dce3667562"
xmlns="http://www.intuit.com/sb/cdm/v2"><ExternalRealmId>570357960</ExternalRealmId><Objectxsi:type="Account"><Name>CurrentAccount</Name><Active>true</Active><Type>Expense<
/Type><Subtype>Expense</Subtype><AcctNum>1111</AcctNum></Object></Add>
And getting the response (error in html):
<div class="content-container"><fieldset>
<h2>500 - Internal server error.</h2>
<h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
and I have also checked with RESTClient utility, but getting the same above error.
Please note that the same url
(https://services.intuit.com/sb/account/v2/570357960) with same
security tokens is working fine for GET data , I am getting data from
QB desktop into my online Application.
As Keith said, check the Content-Type. You will also need to use a RestClient for testing. The playground will not work for testing API calls. It only works for platform calls.
If I had to guess... I'd guess you're sending the wrong Content-Type header... but it's impossible to tell for sure until you post more code/the rest of your HTTP request.
A few things to try. Be sure the XML is in the same order as this sample and try it.
the other is a common mistake when you use Oauth in a GET you are including just the url in the signature, but in a POST you need to include the Body in the signature too or it will not pass Oauth validation.
Lastly, as Keith mentioned to check the content type. Although you would generally get a content type error.
156234822
CurrentAccount
true
Expense
Expense
1111