Skip to Content
Author's profile photo Biplab Ray

Way to Post SOAPMessage to WMB End Point using Java

Applies To: JDK 1.5 onwards

Author(s):      Biplab Ray

Company:      Tata Consultancy Services

Created on:    03rd March 2015

Author Bio:

Biplab Ray is working for Tata Consultancy Services as Assistant Consultant and development of SAP EP, composite applications using CAF, BPM, BRM, WebDynpro for Java. He also works in technologies like Java/J2EE and has depth understanding on eSOA, Webservice, Enterprise Service, XML.


In many businesses application we might encountered a situation when we have to hand shake between AS Java servers with Web Sphere Message Broker.


We have to write below method to communicate between two servers.

Imports are as below:




import javax.xml.soap.SOAPException;

import javax.xml.soap.SOAPMessage;

import javax.xml.soap.SOAPConnection;

import javax.xml.soap.SOAPConnectionFactory;

Method as below:

public static SOAPMessage SOAP_Connection_SAP(SOAPMessage message, String string_END_POINT){

            SOAPMessage reply = null;

            long begintime = -1;

            long endtime = -1;

            try {


                  SOAPConnection connection  = SOAPConnectionFactory.newInstance().createConnection();


                  URL endpoint = new URL(null, string_END_POINT,

               new URLStreamHandler() {


                  protected URLConnection openConnection(URL url) throws IOException {

                  URL target = new URL(url.toString());

                  URLConnection connection = target.openConnection();

                  // Connection settings

connection.setReadTimeout(1200000); // 20 mins





                  reply =, endpoint);





            catch (IOException e) {

                  // TODO: handle exception




            catch (UnsupportedOperationException e) {

                  // TODO Auto-generated catch block


            } catch (SOAPException e) {

                  // TODO Auto-generated catch block


            } catch (Exception e) {

                  // TODO Auto-generated catch block






            return reply;


So, from the application if we call the above method we will get a SOAP Message as response as well.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jun Wu
      Jun Wu

      better enrich it regarding how to use it in sap environment

      just dump some java code, what's the point?

      Author's profile photo Biplab Ray
      Biplab Ray
      Blog Post Author

      If u want to post custom SOAP message to WMB or IEB end point, I don't think there is any standard solution for that. Before implementation we have already discussed with SAP fellow regarding that, then we have implemented our custom solution.

      And one more point, am providing this blogs only to help other fellow who are working on the similar kind of work.

      If u have some better solution provide in the forum.

      And the blog is not just a dump of java code. If u have idea u could develop with help of the code.

      In the forum all the professional should communicate with other with respect.