0

我有一个客户端将请求作为“GET”而不是“POST”发送到我的 cxf jax-ws Web 服务

根据this answer link Webservice has "No such operation: HTTP GET PATH_INFO",它应该是“POST”。我已经搜索了如何在 cxf 中将 HTTP-Method 设置为“POST”,但没有得到太多帮助。我发现 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>
--------------------------------------
4

1 回答 1

0

最近我遇到了同样的问题。遇到的错误是:

引起:javax.wsdl.WSDLException:WSDLException:faultCode=PARSER_ERROR:解析“http://172.22.2.7/enmac/SOAP”时出现问题。:java.io.IOException:服务器返回 HTTP 响应代码:405 用于 URL:http: //172.22.2.7/enmac/SOAP

它还显示诸如“不允许获取方法”之类的错误

出现问题的原因:SOAP 始终使用 HTTP/S over POST 请求。当我们从 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 绑定等所有问题。

最好的问候 Hitesh

于 2021-05-05T05:35:09.017 回答