You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Doug Schaible <do...@gmail.com> on 2007/05/19 02:35:00 UTC

Capturing the SOAP Message

Good Evening Everyone,

I have been working for several weeks to create a SOAP client using AXIS to
call a .Net Web Service.  I would like to be able to capture the actual SOAP
message that is being sent.

>From the WSDL file I ran WDSL2Java and then created this code for my
application:

 try
 {
  Login LoginData = new Login();
  LoginResponse LoginDataResponse = new LoginResponse();
  ServiceLocator loc = new ServiceLocator();
  ServiceSoap port = loc.getServiceSoap();
  LoginDataResponse = port.login(LoginData);
  out.println( "LoginDataResponce" + LoginDataResponse.toString() );
 }
 catch (java.rmi.RemoteException e)
 {
  out.println("<p>Remote Server Exception Message: " + e.getMessage() );
   }
 catch (Exception e)
 {
    out.println("This is an exception: " + e.toString());
 }

If anyone can tell me how to capture the actual SOAP message that is being
sent it would be great.

Also, if you notice anything in my code that does not appear correct please
let me know.  Help is much appreciated.

Thanks,
Doug

Re: Capturing the SOAP Message

Posted by Demetris G <de...@ece.neu.edu>.
Can't you listen to the port that Axis will be wrtiting at using the 
locahost (127.0.0.1)
and print out the SOAP as XML text? Isn't that what you want to do?

Martin Gainty wrote:
> Hard to determine what your looking for but looking at your 
> ServiceLocator code the chronology would be something like:
> //Assuming your class is called ObjectType you should declare your own 
> ObjectTypeServiceLocator
> ServiceLocator loc = new ServiceLocator();
>
> //get the reference to the stored class (Object) via access to the 
> method from the loc object from ServiceLocator
> Object obj= loc.method();
>  
> //If the obj is a primitive type (String,Integer) then cast the obj 
> obtained from the loc.method to expected DataType (for sake of 
> argument we'll use String)
> String str = (String)obj;
>  
> //If this NOT a primitive type (in other words some manner of Complex 
> or class object) access the individual attributes
> //Now You will be able to print the result
> System.out.println(str);
>  
> //there is a comprehensive example located at 
> $AXIS_HOME/addr/Main.java which calls the AddressBookServiceLocator which
> //constructs the ServiceLocator
> //sets the Default URL
> //executes the doit(ab1) to populate the object and then access
> //prints the response from the service's methods with declared print 
> methods
>  
> //If on the other hand you want a more comprehensive tool to view ALL 
> SOAP requests and responses I would look at tcpmon available at
> http://ws.apache.org/commons/tcpmon/
>  
> M--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please 
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
>
>     ----- Original Message -----
>     *From:* Doug Schaible <ma...@gmail.com>
>     *To:* axis-user@ws.apache.org <ma...@ws.apache.org>
>     *Sent:* Friday, May 18, 2007 8:35 PM
>     *Subject:* Capturing the SOAP Message
>
>      
>     Good Evening Everyone,
>      
>     I have been working for several weeks to create a SOAP client
>     using AXIS to call a .Net Web Service.  I would like to be able to
>     capture the actual SOAP message that is being sent. 
>      
>     From the WSDL file I ran WDSL2Java and then created this code for
>     my application:
>      
>      try
>      {
>       Login LoginData = new Login();
>       LoginResponse LoginDataResponse = new LoginResponse();
>       ServiceLocator loc = new ServiceLocator();
>       ServiceSoap port = loc.getServiceSoap();
>       LoginDataResponse = port.login(LoginData);
>       out.println( "LoginDataResponce" + LoginDataResponse.toString() );
>      }
>      catch (java.rmi.RemoteException e)
>      {
>       out.println("<p>Remote Server Exception Message: " +
>     e.getMessage() );
>        }
>      catch (Exception e)
>      {
>         out.println("This is an exception: " + e.toString());
>      }
>      
>     If anyone can tell me how to capture the actual SOAP message that
>     is being sent it would be great.
>      
>     Also, if you notice anything in my code that does not appear
>     correct please let me know.  Help is much appreciated.
>      
>     Thanks,
>     Doug
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Capturing the SOAP Message

Posted by Martin Gainty <mg...@hotmail.com>.
Hard to determine what your looking for but looking at your ServiceLocator code the chronology would be something like:

//Assuming your class is called ObjectType you should declare your own ObjectTypeServiceLocator
ServiceLocator loc = new ServiceLocator();

//get the reference to the stored class (Object) via access to the method from the loc object from ServiceLocator
Object obj= loc.method();

//If the obj is a primitive type (String,Integer) then cast the obj obtained from the loc.method to expected DataType (for sake of argument we'll use String)
String str = (String)obj;

//If this NOT a primitive type (in other words some manner of Complex or class object) access the individual attributes 
//Now You will be able to print the result
System.out.println(str);

//there is a comprehensive example located at $AXIS_HOME/addr/Main.java which calls the AddressBookServiceLocator which
//constructs the ServiceLocator
//sets the Default URL
//executes the doit(ab1) to populate the object and then access
//prints the response from the service's methods with declared print methods

//If on the other hand you want a more comprehensive tool to view ALL SOAP requests and responses I would look at tcpmon available at
http://ws.apache.org/commons/tcpmon/

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

  ----- Original Message ----- 
  From: Doug Schaible 
  To: axis-user@ws.apache.org 
  Sent: Friday, May 18, 2007 8:35 PM
  Subject: Capturing the SOAP Message



  Good Evening Everyone,

  I have been working for several weeks to create a SOAP client using AXIS to call a .Net Web Service.  I would like to be able to capture the actual SOAP message that is being sent. 

  From the WSDL file I ran WDSL2Java and then created this code for my application:

   try
   {
    Login LoginData = new Login();
    LoginResponse LoginDataResponse = new LoginResponse();
    ServiceLocator loc = new ServiceLocator();
    ServiceSoap port = loc.getServiceSoap();
    LoginDataResponse = port.login(LoginData);
    out.println( "LoginDataResponce" + LoginDataResponse.toString() );
   }
   catch (java.rmi.RemoteException e)
   {
    out.println("<p>Remote Server Exception Message: " + e.getMessage() );
     }
   catch (Exception e)
   {
      out.println("This is an exception: " + e.toString());
   }

  If anyone can tell me how to capture the actual SOAP message that is being sent it would be great.

  Also, if you notice anything in my code that does not appear correct please let me know.  Help is much appreciated.

  Thanks,
  Doug