aspose file tools*
The moose likes Web Services and the fly likes How to capture the soap envelop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to capture the soap envelop " Watch "How to capture the soap envelop " New topic
Author

How to capture the soap envelop

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
I am running the chapter 2 example code from Java web service up and running by Martin Kalin.
How to capture the SOAP envelop ?
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 410
    
    3
1. tool-wise, Use tcp/ip to see the request/response soap message

2. code-wise, implements javax.xml.ws.handler.LogicalHandler.
the book should talk about it since it's about soapful webservice jax-ws

See package Package javax.xml.ws.handler
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
The book talks about tcpmon. In chapter 1, the client use port 8080 to connect to tcpmon. The tcpmon uses 9876 to connect to the web service of TimeServerImpl.
But how to connect from my client app to AwsEcommerceService in chapter 2? The port numbers are not specified in the code.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 410
    
    3
1. look into the doc on how to use tcp/ip mon.
2. navigate thru classses/method where you will see the wsdl url where you can see soap address where you can see the port
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734


In the above wsimport generated code from Amazon's wsdl, I don't see any port number and server name from Amazon.
I cannot use Eclipse' TCP/IP monitor to capture the SOAP messages.
jhessica valdez
Greenhorn

Joined: Feb 01, 2013
Posts: 5
I spend quite a bit of time on the PayPal Developer Community forum trying to help other developers with integration problems. When asking questions about the PayPal SOAP API, many people will post the SOAP envelope that they're sending to the API. Since that is the actual request stream that's sent to the web service, it seems like the best way to verify exactly what you're requesting.

ASP.NET has done a great job of abstracting the whole SOAP request/response process. When you add a web reference to the PayPal SOAP API web service, it appears as a collection of classes with properties and methods for working with the API. There is no dealing with XML, just instantiate the objects, set the necessary properties, and call the desired methods -- object oriented design at its finest.

In fact, it is abstracted so well, there is no simple way to view the actual XML documents that are sent back and forth between your application and the web service. After a bit of research, I found that Microsoft has provided the functionality I was looking for in the way of SOAP Extensions. I found what I needed here:

http://msdn2.microsoft.com/en-us/library/system.web.services.protocols.soapextension(VS.80).aspx

and here:

http://msdn2.microsoft.com/en-us/library/b5e8e7kk(VS.80).aspx.
chaitanya sarvepalli
Greenhorn

Joined: Jan 07, 2013
Posts: 4
Hi,
This is my first post, I couldn't able to attach jar file, probably because of site restriction.

I have shared the jar file at https://docs.google.com/file/d/0B0jSBr_NvThZNVNMYTBWR3BTRzA/edit?usp=sharing


The below readme file assumes, you have already generated client artifacts and you have a WebService Client class...

Hope it will answer your question.. let me know if that helps.


README for Soap Handler:
-------------------------

Include the soaphandler.jar file in class path

@HandlerChain(file="/com/handler/handler-chain.xml")
incldue the Handler chain Annotation, with WebService client. just below @WebServiceClient annotation

This handler will print the soap incoming and outgoing messages in logs.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
Hi, Chaitanya.
Thanks for your jar file.
But in the AmazonClientW.java, it does not have a @WebService.

Should I put @HandlerChain (...) below the class AmazonClientW in the code?
Is the handler-chain.xml inside the jar file?
chaitanya sarvepalli
Greenhorn

Joined: Jan 07, 2013
Posts: 4
when you have created the client artificats using wsimport, there is a Service proxy class which was annotated with @WebServiceClient
File Name: AWSECommerceService.java
you can edit this java file, add HandlerChain annotation. re-compile the java file.
yes, the handler chain xml file is available with in the jar file...

If you are not interested to go this approach, there is another choice.
you can add Handlers programmatically using HandlerResolvers.

Create the following ClientHandlerResolver class.




Now add this HandlerResolver manually to your AmazonClientW client program.



probably this should resolve your issue.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
Hi, I tried both approaches:


When line 3 is commented out, it won't work.

I tried the second approach:


This one does not print out the SOAP messages.

Please help if you have any idea.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
Hi,
I combined the two approaches.
The AwsHandlerResolver was provided on the web.
I modified the getHandlerChain by adding the com.handler.MyHandler.

It works now. I prints out the outgoing and incoming SOAP messages.

 
 
subject: How to capture the soap envelop