Tracing XML request/responses with JAX-WS when err

2019-01-10 15:42发布

I want to log raw soap post requests if there are any errors , I am using JAX-WS. Any help will be appreciated.

Is there an easy way (aka: not using a proxy) to get access to the raw request/response XML for a webservice published with JAX-WS reference implementation (the one included in JDK 1.5 and better) only when exception occurs in response? I want to log raw SOAP reuest so that I can test it thorugh any webservice client at a later stage

标签: java jax-ws
7条回答
姐就是有狂的资本
2楼-- · 2019-01-10 15:49

I think that what you need is an handler, see: http://jax-ws.java.net/articles/handlers_introduction.html
With handler you can intercept web service call, and have access to all the SOAP message.

查看更多
再贱就再见
3楼-- · 2019-01-10 15:50

If you working with Jboss 6.1 and you want to print the logs for the JAX-WS generated classes request to the SOAP web service, open the file /home/oracle/jboss-eap-6.1/bin/standalone.sh note: please go where you have installed jboss

You will find something like this

JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n"

Change it to the one shown below

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n"

Also make sure you enable debug

DEBUG_MODE=true
查看更多
【Aperson】
4楼-- · 2019-01-10 15:52

This worked for me:

-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
查看更多
走好不送
5楼-- · 2019-01-10 15:54

The first thing you might want to try is using one, or both, of the following system properties:

Client:

com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true

Server:

com.sun.xml.ws.transport.http.HttpAdapter.dump=true
查看更多
走好不送
6楼-- · 2019-01-10 16:07

Just thought I would mention this:

The question when to use the property name with the internal in it and when not ?

If you read the Metro Guide it will tell you to use:

on client:

com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true

on server:

com.sun.xml.ws.transport.http.HttpAdapter.dump=true

However: It seems to me that when JAX-WS RI library got included as standard with the JDK (this was with Java 6) then Sun had to rename the property name to include 'internal'. So if you are using JAX-WS RI as it comes bundled with the JDK, then you must be sure to add the internal to the property name. Otherwise it will not work. In other words you need to use:

on client:

com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true

on server:

com.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true

On the other hand if you are using a standalone version of JAX-WS RI (or of Metro as a whole) then I would guess you should use the property name without the internal.

I'll be glad if someone has inside knowledge on this and can say if this is true or not.

查看更多
贼婆χ
7楼-- · 2019-01-10 16:10

Use

com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true

and

com.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true

instead (note the "internal" in the package name), this did the trick for me.

Cheers, Torsten

查看更多
登录 后发表回答