Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

issue wsdl call java example

String xml = "<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
" +
  "  <s:Body>
" +
  "       <GetInternalVal xmlns="http://someuri.org/">
" +
  "          <username>some_user</username>
" +
  "          <password>" +some_password+ "</password>
" +
  "          <domain>EARTH</domain>
" +
  "       </GetInternalVal>
" +
  "  </s:Body>
" +
  "</s:Envelope>
";

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_XML);
headers.set("soapaction", "http://someuri.org/MyService/GetData");

HttpEntity<String> request = new HttpEntity<String>(xml, headers);

String response = this.restTemplate.exchange("http://myhost.stage.com/someservice/InternalVal.svc?wsdl=",HttpMethod.POST, request, String.class).getBody();

/*Parse the XML response*/
/*
	<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
          <GetInternalValResponse xmlns="http://someuri.org/">
              <GetInternalVal>
                  HelloWorld
              </GetInternalVal>
          </GetInternalValResponse>
      </s:Body>
	</s:Envelope>
*/
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(response));

Document doc = documentBuilder.parse(inputSource);
NodeList nList = doc.getElementsByTagName("GetInternalVal");

Node node = nList.item(0);
String internalVal = node.getTextContent();

return internalVal;
 
PREVIOUS NEXT
Tagged: #issue #wsdl #call #java
ADD COMMENT
Topic
Name
8+8 =