使用Apache CXF的Web服务响应显示“没有绑定操作信息..”

时间:2013-02-05 10:31:46

标签: java eclipse web-services cxf

问题描述可能很长。请耐心等待并提供任何帮助,因为我不熟悉网络服务。

我做了什么: 我使用Apache CXF RI在java中创建了一个Web服务。我只是创建了一个类,并使用自下而上的开发方法来生成SEI,WSDL和XML文件。

问题是什么: 现在,如果我请求“http://localhost:8084/DeepThoughtWS/services/DeepThoughtPort/whatIsTheAnswer”,它会生成输出 没有绑定操作信息,同时调用未知方法未知的方法。 答复如下:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>No binding operation info while invoking unknown
      method with params unknown.</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

生成的WSDL是:

<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.service.com/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="DeepThoughtService" targetNamespace="http://ws.service.com/">
  <wsdl:types>
    <schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://ws.service.com/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns="http://www.w3.org/2001/XMLSchema">
      <import namespace="http://ws.service.com/"
      schemaLocation="http://localhost:8084/DeepThoughtWS/services/DeepThoughtPort?xsd=deepthought_schema1.xsd" />
    </schema>
  </wsdl:types>
  <wsdl:message name="whatIsTheAnswerResponse">
    <wsdl:part element="tns:whatIsTheAnswerResponse"
    name="parameters"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="whatIsTheAnswer">
    <wsdl:part element="tns:whatIsTheAnswer" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="DeepThought">
    <wsdl:operation name="whatIsTheAnswer">
      <wsdl:input message="tns:whatIsTheAnswer"
      name="whatIsTheAnswer"></wsdl:input>
      <wsdl:output message="tns:whatIsTheAnswerResponse"
      name="whatIsTheAnswerResponse"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="DeepThoughtServiceSoapBinding"
  type="tns:DeepThought">
    <soap:binding style="document"
    transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="whatIsTheAnswer">
      <soap:operation soapAction="" style="document" />
      <wsdl:input name="whatIsTheAnswer">
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output name="whatIsTheAnswerResponse">
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="DeepThoughtService">
    <wsdl:port binding="tns:DeepThoughtServiceSoapBinding"
    name="DeepThoughtPort">
      <soap:address location="http://localhost:8084/DeepThoughtWS/services/DeepThoughtPort" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

DeepThought课程包括:

@WebService(targetNamespace = "http://ws.service.com/", portName = "DeepThoughtPort", serviceName = "DeepThoughtService")
public class DeepThought {
    public String whatIsTheAnswer(@WebParam(name = "arg0") String interviewer) {
        return ("The answer " + interviewer);
    }
}

请求时的控制台输出也显示一些错误:

Feb 05, 2013 3:59:14 PM org.apache.cxf.service.invoker.AbstractInvoker invoke
SEVERE: Invocation without a binding operation.
Feb 05, 2013 3:59:14 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://ws.service.com/}DeepThoughtService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No binding operation info while invoking unknown method with params unknown.
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:59)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:218)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:163)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Feb 05, 2013 3:59:14 PM org.apache.cxf.services.DeepThoughtService.DeepThoughtPort.DeepThought
INFO: Outbound Message
---------------------------
ID: 5
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>No binding operation info while invoking unknown method with params unknown.</faultstring></soap:Fault></soap:Body></soap:Envelope>

5 个答案:

答案 0 :(得分:8)

  

通常,如果传入soap方法,通常会发生此异常   与WSDL不正确匹配。在这种情况下,肥皂消息   无法映射到服务上的适当方法。 CXF就是这样   不知道该怎么办。仔细检查传入的肥皂消息。

Source of the above explanation.

可能的解决方案:

@WebService(targetNamespace = "http://ws.service.com/",
        portName = "DeepThoughtPort",
        serviceName = "DeepThoughtService",
        endpointInterface = "your.pck.DeepThoughtService",
        wsdlLocation = "WEB-INF/wsdl/DeepThoughtService.wsdl")
public class DeepThought {

    @WebMethod(action = "whatIsTheAnswer")
    public String whatIsTheAnswer(@WebParam(name = "arg0") String interviewer) {
        return ("The answer " + interviewer);
    }
}

我要做的是在@WebService中添加WSDL位置和endpointInterface。此外,您使用的是Java-First方法,因此您的方法应使用@WebMethod(action = "whatIsTheAnswer")进行注释。因此,如果该方法未注释CXF“理解”您的网络服务根本不包含任何方法,并说:No binding operation info while invoking unknown method with params unknown.

另见:

答案 1 :(得分:3)

我遇到了同样的问题。使用cxf 2.6 2.7像chrome或firefox这样的Web浏览器的这个请求就没有用了。我尝试在cxf中使用客户端,它的工作原理!您的Web服务正在运行,但您无法通过Web浏览器执行请求,因为客户知道XML的要求,您需要客户端。

答案 2 :(得分:2)

您应该在url的末尾使用wsdl(比如添加?wsdl)进行查询,以检查您的Web服务实现是否有效。浏览器无法作为soap客户端发送任何soap请求。

答案 3 :(得分:1)

是的已经回答您无法在浏览器网址中直接访问该服务。您需要像这样的客户端代码

{{1}}

答案 4 :(得分:1)

有人使用SOAP WebService请求呼叫您的GET,但SOAP WebServices无法收到GET请求。您应该告诉他/她不要使用SOAP WebService请求致电GET或使用GET described here {{1}}来请求我的网络服务。