createFault的错误faultCode参数传递为NULL

时间:2015-04-06 16:51:38

标签: java-ee soap wsdl cxf soapui

您好我是通过SoapUI使用CXF生成客户的,没有给出错误消息或警告,客户端实现如下,我只是设置了我要搜索的对象并进入研究方法,绑定了wsdl搜索方法没有故障操作。

绑定中没有搜索方法的操作。

<wsdl:fault name="fault">
    <soap:fault use="literal" name="fault"/>
  </wsdl:fault>

实施

SearchRestriction search = new SearchRestriction();
        search.setFieldName("Serviço Público:serviceID");
        search.setOperator("EQUALS");
        search.setValue("deleteAddress");

        com.sensedia.repository.wstoolkit.SearchRequest _search_in = new SearchRequest();
        _search_in.getRestrictions().add(search);

        java.util.List<com.sensedia.repository.wstoolkit.SearchResult> _search__return = null;
        try {
            _search__return = port.search(_search_in);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            //e.printStackTrace();
        }

1 个答案:

答案 0 :(得分:0)

如果接收到SOAP响应并且没有有效faultCode argument for createFault was passed NULL子元素的Fault元素,则CXF客户端会生成错误faultCode。捕获SOAP服务器响应并验证其有效性。下面是带有Fault元素的有效SOAP服务器响应的示例。请注意,提供的元素faultcodefaultstring没有命名空间。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode>
         <faultstring xsi:type="xsd:string">Binding error</faultstring>
      </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>