使用CXF处理SOAPAction
我试图弄清楚如何处理SOAP请求,其中SOAPAction是在消息头中指定的,而不是在消息体中指定的。下面是我需要处理的一个请求示例使用CXF处理SOAPAction,soap,cxf,apache-camel,Soap,Cxf,Apache Camel,我试图弄清楚如何处理SOAP请求,其中SOAPAction是在消息头中指定的,而不是在消息体中指定的。下面是我需要处理的一个请求示例 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.afis.com/"> <soapenv:Header/> <soapenv:Body> <S
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.afis.com/">
<soapenv:Header/>
<soapenv:Body>
<String>12</String>
</soapenv:Body>
</soapenv:Envelope>
以下是界面:
@WebService
public interface CCHEndpoint {
@WebMethod(operationName = "process", action = "urn:process")
public String process(@WebParam(partName = "String", name = "String")String string);
}
如果我提交的请求在XML中没有process元素(但在SOAP头中),我会得到以下结果:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unexpected wrapper element String found. Expected {http://soap.afis.com/}process.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
soap:客户端
找到意外的包装器元素字符串。期望{http://soap.afis.com/}过程。
请注意,使用Axis2,我能够处理此类请求,因为services.xml为我们将操作映射到操作,但我无法将Axis2用于此项目。我需要一个与CXF等效的机制。我觉得cxfEndpoint中的额外配置,或者可能是一个注释,但我找不到解决方案。请求中的
元素实际上与操作无关。这是一个包装器元素。根据JAX-WS规范,默认情况下,服务是在“包装”模式下创建的,其中有一个包装器元素作为soap主体的直接子元素。如果您不想这样做,只想直接获得操作参数,那么您需要在界面上添加@SOAPBinding(parameterStyle=SOAPBinding.parameterStyle.BARE)
注释。谢谢!这正是我需要的
@WebService(serviceName = "com.CCHEndpoint")
public class CCHEndpointImpl implements CCHEndpoint {
@Override
@WebMethod(operationName = "process", action = "urn:process")
public String process(@WebParam(partName = "String", name = "String") String string) {
return "sd";
}
}
@WebService
public interface CCHEndpoint {
@WebMethod(operationName = "process", action = "urn:process")
public String process(@WebParam(partName = "String", name = "String")String string);
}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unexpected wrapper element String found. Expected {http://soap.afis.com/}process.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>