我有一个客户端向我的cxf jax-ws网络服务发送请求为" GET"而不是" POST"
根据这个答案链接Webservice having "No such operation: HTTP GET PATH_INFO",它应该是" POST"。我已经搜索了如何将HTTP-Method设置为" POST"在cxf,但无法得到很多帮助。我发现Message类中有一个常量字符串HTTP_REQUEST_METHOD,但无法找到有关如何使用它的任何信息。请帮忙。
这是堆栈跟踪:
ID: 4
Address: http://localhost/ws/services/NTServiceHttpSoapEndpoint
Http-Method: GET
Content-Type:
Headers: {Accept=[text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2], cache-control=[no-cache], connection=[keep-alive], Content-Type=[null], host=[10.19.9.80:8080], pragma=[no-cache], user-agent=[Java/1.7.0_10]}
--------------------------------------
> Jul 22, 2016 9:15:58 PM org.apache.cxf.phase.PhaseInterceptorChain
> doDefaultLogging WARNING: Interceptor for
> {http://example.com/wsdl/service/nm/triggering/v3_0}NTriggeringService
> has thrown exception, unwinding now org.apache.cxf.interceptor.Fault:
> No such operation: (HTTP GET PATH_INFO:
> /ws/services/NotificationManagerTriggeringServiceHttpSoapEndpoint) at
> org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:93)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:237)
> at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:239)
> at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:213)
> at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:131)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:266)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:191)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:242)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
> at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:745)
Jul 22, 2016 9:15:58 PM org.apache.cxf.services.NotificationManagerTriggeringService.NotificationManagerTriggeringServiceHttpSoapEndpoint.NotificationManagerTriggeringServicePortType
INFO: Outbound Message
---------------------------
ID: 4
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 such operation: (HTTP GET PATH_INFO: /ws/services/NTHttpSoapEndpoint)</faultstring></soap:Fault></soap:Body></soap:Envelope>
--------------------------------------
答案 0 :(得分:0)
最近我遇到了同样的问题。遇到的错误是:
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://172.22.2.7/enmac/SOAP'.: java.io.IOException: 服务器返回 HTTP响应代码:405 对应 URL:http://172.22.2.7/enmac/SOAP
它也显示了“不允许获取方法”之类的错误
问题原因: SOAP 始终通过 POST 请求使用 HTTP/S。当我们从 SOAP UI 发送 SOAP 请求时,它会自动将请求绑定到 Post 请求。因此,应用程序代码以某种方式将请求绑定到 Get。因此,Web Service Client 的创建方式存在问题。
分辨率: 最初,我使用以下代码调用客户端 Web 服务:
事件 ss = 新事件(wsdlURL, SERVICE_NAME); IncidentSoap 端口 = ss.getIncidentSoap()
这造成了问题。解决方法是使用 org.apache.cxf.jaxws.JaxWsProxyFactoryBean 创建 Web 服务实例。 Apache CXF 还生成了一个客户端 bean xml,内容如下:
因此,我使用了 Spring 管理的客户端对象和 BINGO,它奏效了。我相信当我们以这种方式创建 Web 服务实例时,它会处理 HTTP 绑定等所有事情。
最好的问候 热门