我有一个带注释的JAX Web服务:
@WebMethod(action = "http://my.services/ITService/postIT")
@WebResult(name = "postITResponseTypeDef", targetNamespace = "http://my.services/ITService/", partName = "parameters")
public ResponseParameterList postIT(
@WebParam(name = "postITRequestTypeDef", targetNamespace = "http://my.services/ITService/", partName = "parameters")
PostITRequestTypeDef parameters,
@WebParam(name = "ITHeaderTypeDef", targetNamespace = "http://my.services/ITService/", header = true, partName = "request_Header")
ITHeaderTypeDef requestHeader)
throws ITSoapException
;
在实现此服务的类中,我需要访问SOAP请求的原始xml(最好是作为String)。我怎样才能访问它?
谢谢!
答案 0 :(得分:0)
这可以使用SOAP消息处理程序完成:
public class CustomAddressValidatorHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(SOAPMessageContext context) {
...
}
}
需要一个handler-chain.xml文件来插入JAX-WS链:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<javaee:handler-chains
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<javaee:handler-chain>
<javaee:handler>
<javaee:handler-class>package.handler.CustomAddressValidatorHandler</javaee:handler-class>
</javaee:handler>
</javaee:handler-chain>
</javaee:handler-chains>
这会将处理程序应用于请求:
@WebService
@HandlerChain(file="handler-chain.xml")
public class ServerInfo {
...
}
另请查看此tutorial。