SOAPMessage get(Object to) Method



Description

The javax.xml.soap.SOAPConnection.get(Object to) method closes this SOAPConnection object.

Declaration

Following is the declaration for javax.xml.soap.SOAPConnection.get(Object to) method

SOAPMessage get(Object to) 

Exception

SOAPException − if there is a SOAP error.

Example

The following example shows the usage of javax.xml.soap.SOAPConnection.get(Object to) method.

package com.tutorialspoint;

import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;

public class SoapConnectionDemo {
   public static void main(String[] args) {
      try {
         //create a default soap factory using SoapFactory implementation of 
         //SAAJMetaFactory.newSOAPFactory(String protocol)
         SOAPFactory messageFactory = SOAPFactory.newInstance(
            SOAPConstants.SOAP_1_2_PROTOCOL);
    	  
         // create a new SOAPMessage
         SOAPMessage message = MessageFactory
            .newInstance()
            .createMessage();
         
         SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

         // print SOAP Response
         System.out.print("Response SOAP Message:");
         soapResponse.writeTo(System.out);

         soapConnection.close();
         
      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
}

If we compile the code and execute it, this will produce the following result:

Mime Header Name: Content-Type
Mime Header value: text/xml
Mime Header Name: Encoding
Mime Header value: UTF-8
javax_xml_soap_soapconnection.htm
Advertisements