How do I log into SalesForce using SOAP in JMeter? - soap

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,

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.

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 do I convert a SOAP Envelop into JSON?

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)

error="insufficient_scope" when accessing yahoo Japan API order info

I have a problem when using yahoo Japan API.
When using order info API, the server always returns an error:
<?xml version="1.0" encoding="utf-8" ?>
<Error>
<Message>
Please provide valid credentials. Bearer realm="yahooapis.jp", error="insufficient_scope", error_description="insufficient scope"
</Message>
</Error>
Here is my request:
https://circus.shopping.yahooapis.jp/ShoppingWebService/V1/orderInfo
Authorization: Bearer accessToken
<Req>
<Target>
<OrderId>orderId here</OrderId>
<Field>PayStatus,SettleStatus</Field>
</Target>
<SellerId>sellerId here</SellerId>
</Req>
So, maybe you think my accessToken is expired or invalidate. But when I use this accessToken to access user info API, it's work, so the accessToken is not a problem.
https://userinfo.yahooapis.jp/yconnect/v1/attribute?schema=openid
Authorization: Bearer accessToken
I don't know what's wrong with my request, maybe you know. Thanks.
Update:
For people who have the same problem, here is my solution.
You need to contact with yahoo to ask them allow you permissions to use shopping API. That's it :))
I was also facing the same issue so what i did while doing authorization i added scope keyword in request params and while access yahoo site it ask me to give permission for other information like email, name and etc. so its works fine after that. check params added while authorization.
'scope' => $scope
home this will help you..

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