Android 给定的 SOAPAction 与操作不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12220851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The given SOAPAction does not match an operation
提问by user1639443
I'm new to web service using jax-ws. I was starting to implement it based on some kind of tutorials over the web. Moreover, I was trying to access that service through my android client so I was calling this.
我是使用 jax-ws 的 Web 服务的新手。我开始根据网络上的某种教程来实现它。此外,我试图通过我的 android 客户端访问该服务,所以我正在调用它。
private static final String SOAP_ACTION = "http://service.my/sayHello";
androidHttpTransport.call(SOAP_ACTION, envelope);
But I get this error when i try to printstacktrace.
但是当我尝试打印堆栈跟踪时出现此错误。
WARNING: Interceptor for {http://service.my/}HelloServiceImplService#{http://service.my/}sayHello has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: The given SOAPAction http://service.my/sayHello does not match an operation.
at org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor$SoapActionInAttemptTwoInterceptor.handleMessage(SoapActionInInterceptor.java:188)
at org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor$SoapActionInAttemptTwoInterceptor.handleMessage(SoapActionInInterceptor.java:162)
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:207)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:191)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
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:225)
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:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
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:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
This is my WSDL by the way:
顺便说一下,这是我的 WSDL:
<wsdl:definitions xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.my/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HelloServiceImplService" targetNamespace="http://service.my/">
<wsdl:types>
<xs:schema xmlns:tns="http://service.my/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://service.my/" version="1.0">
<xs:element name="sayHello" type="tns:sayHello"/>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloResponse">
<wsdl:part element="tns:sayHelloResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloService">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:sayHello" name="sayHello"></wsdl:input>
<wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceImplServiceSoapBinding" type="tns:HelloService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloServiceImplService">
<wsdl:port binding="tns:HelloServiceImplServiceSoapBinding" name="HelloServiceImplPort">
<soap:address location="http://192.168.0.102:8080/TestWS/myService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
回答by Daniel Kulp
According to your WSDL:
根据您的 WSDL:
<soap:operation soapAction="" style="document"/>
The SOAPAction should be an empty string, not "http://service.my/sayHello".
SOAPAction 应该是一个空字符串,而不是“http://service.my/sayHello”。
回答by Paulius Matulionis
Your SOAP
action should look like this: {http://service.my/}sayHello
if you specify it like this: http://service.my/sayHello
CXF
does not understands that this is an action, this looks more like a name space, not an action.
你的SOAP
动作应该是这样的:{http://service.my/}sayHello
如果你这样指定:http://service.my/sayHello
CXF
不知道这是一个动作,这看起来更像是一个命名空间,而不是一个动作。
Change this:
改变这个:
private static final String SOAP_ACTION = "http://service.my/sayHello";
into this:
进入这个:
private static final String SOAP_ACTION = "{http://service.my/}sayHello";
And it should work.
它应该工作。
回答by Anderson Mao
I encountered similar issue like "The given SOAPAction ... does not match an operation" when using CXF JAX-WS. If you use the JAX-WS proxy like below
我在使用 CXF JAX-WS 时遇到了类似的问题,例如“给定的 SOAPAction ... 与操作不匹配”。如果您使用如下所示的 JAX-WS 代理
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(endpointAddress);
XXXServicePortType port = factory.create(XXXServicePortType.class);
// (set HTTP header here)
port.someMethod()
It is caused by the HTTP header "SOAPAction" not set to "" You can set it by below code: place to (set HTTP header here)
它是由 HTTP 标头“SOAPAction”未设置为“”引起的,您可以通过以下代码进行设置:place to(在此处设置 HTTP 标头)
org.apache.cxf.endpoint.Client proxy = ClientProxy.getClient(port);
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("SOAPAction", Arrays.asList(""));
proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
回答by Petter Ivarsson
I got this message when I used System.Net.WebClient. SoapAction was sent in header and I reused the client for 2 operations before dispose, so on the second call it sent 2 actions... Clear() before each call solved the problem.
我在使用 System.Net.WebClient 时收到此消息。SoapAction 是在标头中发送的,我在处理之前将客户端重用于 2 个操作,因此在第二次调用时它发送了 2 个动作......在每次调用解决问题之前清除()。