Exemplo de SOAPMessageV2 direto
Você pode enviar uma mensagem SOAP de saída diretamente para o endpoint.
Neste exemplo, o script envia uma mensagem SOAP solicitando uma cotação de ação e aguarda uma resposta. Se não houver resposta do provedor de serviço Web ou se o registro de mensagem SOAP especificado estiver indisponível, o script emitirá um erro, tratado neste exemplo pelo bloco tentar-catch.
var requestBody;
var responseBody;
var status;
var sm;
try{
sm = new sn_ws.SOAPMessageV2("StockQuote", "GetQuote"); // Might throw exception if message doesn't exist or not visible due to scope
sm.setBasicAuth("admin","admin");
sm.setStringParameter("symbol", "NOW");
sm.setStringParameterNoEscape("xml_data","<data>test</data>");
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;
}
gs.info("Request Body: " + requestBody);
gs.info("Response: " + responseBody);
gs.info("HTTP Status: " + status);