Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Direct SOAPMessageV2 example

Log in to subscribe to topics and get notified when content changes.

Direct SOAPMessageV2 example

You can send a SOAP message directly to the endpoint.

In this example, the script sends a SOAP message requesting a stock quote and waits for a response. If there is no response from the web service provider, or if the specified SOAP message record is unavailable, the script throws an error, handled in this example by the try-catch block.

var requestBody;
var responseBody;
var status;
var sm;
	sm = new sn_ws.SOAPMessageV2("StockQuote", "GetQuote");  // Might throw exception if message doesn't exist or not visible due to scope
	sm.setStringParameter("symbol", "NOW");
	sm.setHttpTimeout(10000) //In Milli seconds. Wait at most 10 seconds for response from http request.

	response = sm.execute();//Might throw exception if http connection timed out or some issue with sending request itself because 	of encryption/decryption of password and stuff
	responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
	status = response.getStatusCode();
} catch(ex) {
	responseBody = ex.getMessage();
	status = '500';
} finally {
	requestBody = sm ? sm.getRequestBody():null;
}"Request Body: " + requestBody);"Response: " + responseBody);"HTTP Status: " + status);