Apache 如果wsdl中不存在端点,则处理错误字符串消息

Apache 如果wsdl中不存在端点,则处理错误字符串消息,apache,cxf,Apache,Cxf,我在尝试从SOAPUI调用服务时遇到以下异常,这很好 因为消息部分元素在wsdl中不存在。 但我希望在CXF web服务中以正确的方式进行处理,并发送正确的错误字符串,而不是下面的消息ex:Bad Request <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <Action xmlns="http://www.w3.org/2

我在尝试从SOAPUI调用服务时遇到以下异常,这很好 因为消息部分元素在wsdl中不存在。 但我希望在CXF web服务中以正确的方式进行处理,并发送正确的错误字符串,而不是下面的消息ex:Bad Request

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <Action xmlns="http://www.w3.org/2005/08/addressing"/>
      <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:109a84f4-373d-4406-9087-82bd58bea394</MessageID>
      <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
      <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">uuid:3dcf9e26-20fc-4c93-bc01-8ca9ab1ae2eb</RelatesTo>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Message part Reservation was not recognized.  (Does it exist in service WSDL?)</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

在cxf中,有人知道我可以在哪里以适当的方式处理吗?

您可以通过使用客户端应用程序的web服务来解决这个问题。在需要使用WS的任何地方,都应该将BindingProvider放在端口上。此示例是一种方法:

...
import javax.xml.ws.BindingProvider;

public class WSClient {

        public String getUserName(int userCode) {

            WebServiceAuth ss = new WebServiceAuth();
            IWebServiceAuth port = ss.getPort(IWebServiceAuth.class);

            BindingProvider bindingProvider = (BindingProvider) port;
            bindingProvider
                    .getRequestContext()
                    .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                            "http://localhost:8081/WebServiceAuth/WSAuth");

            return port.getUserName(userCode);
        }
}

在这种情况下,您需要将服务地址输入BindingProvider。

可能重复:谢谢帮助。但是我们使用的是最新的版本——它在2.2.5中运行良好。