How do I convert a SOAP Envelop into JSON? - rest

I'm trying to convert this SOAP Envelop into a http POST Request to send via DHC Restlet (or any other engine).
Soap Envelop
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xx="http://xx.webservice.company.com/">
<soapenv:Header/>
<soapenv:Body>
<xx:MyMethodName>
<!--Optional:-->
<firstParameter>xx</firstParameter>
<!--Optional:-->
<secondParameter>zz</secondParameter>
</xx:MyMethodName>
</soapenv:Body>
</soapenv:Envelope>
DHC Implementation
I'm getting 200 OK but the response is empty.
What could I be missing?

Although we can get a result from a GET request, it's not possible to POST a JSON request if your server is using SOAP architecture from behind.
The solution is to POST a SOAP envelop using XML and the following header parameters:
Content-Type : text/xml; charset=utf-8
SOAPAction : (empty)

Related

NetSuite - Postman - REST - "Incorrect data center requested!"

I'm using Postman to connect to NetSuite and all the setup and authorization were made.
When I'm trying to use GET method for a Example template, the request return the Status 200 OK, but with this error?
<?xml version="1.0" encoding="UTF-8"?>
<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>
<soapenv:Fault>
<faultcode>
soapenv:Server.userException
</faultcode>
<faultstring>
Incorrect data center requested! The data center you are requesting is not the data center where your account is hosted. To obtain the correct URL for your request, please use the SOAP getDataCenterUrls operation.
</faultstring>
<detail>
<platformFaults:unexpectedErrorFault xmlns:platformFaults="urn:faults_/services/rest/record/v1/metadata-catalog/customer.platform.webservices.netsuite.com">
<platformFaults:code>
USER_ERROR
</platformFaults:code>
<platformFaults:message>
Incorrect data center requested! The data center you are requesting is not the data center where your account is hosted. To obtain the correct URL for your request, please use the SOAP getDataCenterUrls operation.
</platformFaults:message>
</platformFaults:unexpectedErrorFault>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">
acct027.prod.svale.netledger.com
</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
My URL setup is the same from my Company URL setup:
I've seen other cases like that, and all the responses were related to get the address in the company URL as I've done it.
What can be wrong?
Thank you!
Actually, I had some errors in my postman setup:
The Account_ID, should be entered exactly like this, in capital letters:
But the company URL, and Rest Services should stay like that:
And it worked for me.

How do I log into SalesForce using SOAP in JMeter?

My app usually ask the user to log into SalesForce using this URL.
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=ABC&redirect_uri=http://localhost:3001/callback_URL&state=5abe9eb7b39bae29fcc2dcf9
If successful will call the callbackURL and let the application know login was successful. I would like to mimic this behavior in JMeter.
I tried following the tutorial in this link exactly:
http://blog.deadlypenguin.com/blog/2017/06/29/jmeter-logging-salesforce/
But it's not return a session ID. What am I doing wrong?
Here is how I set it up as per the tutorial:
This is the SalesForce information in step: credentials
Here is the Login Request, as described in step: logging in
Here is the Header config for the login request, as described in the step: loggin in
Here is how I save the convsation, as described in the step: storing session id
Here is what the request sent look like:
POST http://test.salesforce.com/services/Soap/c/42.0
POST data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<urn:login>
<urn:username>USERNAME</urn:username>
<urn:password>PASSWORDTOKEN</urn:password>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
[no cookies]
Request Headers:
Connection: close
Content-Type: text/xml: charset=utf-8
SOAPAction: "urn:enterprise.soap.sforce.com/Soap/loginRequest"
Content-Length: 390
Host: test.salesforce.com
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_161)
And here is the response back:
Formatted XML:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>INVALID_LOGIN</faultcode>
<faultstring>INVALID_LOGIN: Invalid username, password, security token; or user locked out.</faultstring>
<detail>
<sf:LoginFault xsi:type="sf:LoginFault">
<sf:exceptionCode>INVALID_LOGIN</sf:exceptionCode>
<sf:exceptionMessage>Invalid username, password, security token; or user locked out.</sf:exceptionMessage>
</sf:LoginFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I am sure the username and password I used is correct, so there must be some other error. I notice in the tutorial it append the Token after the password. Where do I get that? What token is it talking about?
I am not an expert in sales force. But from your description it looks like you are not passing the security token along with the password which is shown in the reference. So, authentication required "Password + Security token". From your first snapshot, I am getting both. i.e. ${SF_Password}${SF_Token}.
Try it and let us know if it solves the issue or not.
Regards,

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

Accesing the value returned from web service called through soap in iphone

I was working with SOAP to access web service. my question is how to retrieve the value returned from web service
This is my SOAP response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<fnPartyQuestionsPathResponse xmlns="http://QIA/">
<fnPartyQuestionsPathResult>string</fnPartyQuestionsPathResult>
</fnPartyQuestionsPathResponse>
</soap:Body>
</soap:Envelope>
THanks in advance..
wsdl2objc is always worth a look when working with SOAP. It will auto-generate a whole series of classes and objects from your WSDL file (assuming you have access to it) and that makes accessing the data really easy. I've used it on some live projects and find it does what it says on the tin.
You could try using the SudzC library to generate accessor code for your SOAP service, and work with that. I find that it's pretty simple and robust for usage.