Java Web Service Soap故障异常客户端

时间:2014-12-16 11:17:37

标签: java web-services soap wsdl

我正在尝试使用eclipse的java中的Web服务客户端,我收到此错误:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Message part  was not recognized.  (Does it exist in service WSDL?)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:158)
    at com.sun.proxy.$Proxy26.req(Unknown Source)
    at com.caller.main(caller.java:31)
Caused by: org.apache.cxf.binding.soap.SoapFault: Message part  was not recognized.  (Does it exist in service WSDL?)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:849)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1515)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1318)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:572)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:481)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:136)
    ... 2 more

WSDL

<?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions name="test" targetNamespace="http://com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <wsdl:types>
- <schema xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://com/" schemaLocation="test_schema1.xsd" /> 
  </schema>
  </wsdl:types>
- <wsdl:message name="get">
  <wsdl:part name="parameters" element="tns:get" /> 
  </wsdl:message>
- <wsdl:message name="getResponse">
  <wsdl:part name="parameters" element="tns:getResponse" /> 
  </wsdl:message>
- <wsdl:portType name="testPortType">
- <wsdl:operation name="get">
  <wsdl:input name="get" message="tns:get" /> 
  <wsdl:output name="getResponse" message="tns:getResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="testSoapBinding" type="tns:testPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="get">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="get">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="getResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="test">
- <wsdl:port name="testPort" binding="tns:testSoapBinding">
  <soap:address location="http://localhost:8080/testwebserv/services/testPort" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

我删除了我发布此问题的项目,但我创建了一个几乎相同的新项目,但方法名称已更改为get 任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

经过大量调整后我终于发现了问题所在,问题出在package.info上。 旧的package.info就像这样

@javax.xml.bind.annotation.XmlSchema(namespace = "your_namespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

我删除了elementFormDefault,现在它工作得很好。但是有人能告诉我真正的原因是什么,因为我对这项技术不熟悉......