mih*_*ihn 6 java web-services cxf jax-ws
我有一个来自外部WS的WSDL文件,我正在连接到它.我正在尝试使用CXF(与JAX-WS一起使用).但我从其他系统得到错误.所以我决定看一下我们发送到该系统的数据,唯一不同的是CXF设置了空的SOAPAction http头.
我进行了一些阅读,看起来只有已知的解决方案直接指向WSDL.但我已经这样做了.
任何人都有这方面的线索?
<bean id="object" class="xxx.XxxObject" factory-bean="objectFActory"
factory-method="create"/>
<bean id="objectFActory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="xxx.XxxObject"/>
<property name="wsdlLocation" value="http://blebleble"/>
<property name="address" value="http://blebleble"/>
<property name="username" value="user"/>
<property name="password" value="password"/>
<property name="properties">
<map>
<entry key="javax.xml.ws.session.maintain" value-type="java.lang.Boolean" value="true"/>
</map>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
头:
POST /somepath HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
Authorization: Basic <randomhex>
SOAPAction: ""
User-Agent: Apache CXF 2.7.6
Cache-Control: no-cache
Pragma: no-cache
Host: somehost:8080
Connection: keep-alive
Content-Length: 2791
Run Code Online (Sandbox Code Playgroud)
这些都不是CXF特有的.它是所有标准的JAX-WS.
您可以使用@WebMethod批注的action属性来设置SOAP操作.例如
@WebMethod(operationName = "TestOperation", action="http://example.org/TestOperation")
Run Code Online (Sandbox Code Playgroud)
如果您使用wsimport从WSDL生成工件,那么您应该已经在@WebService注释接口中使用了此set .
我能够使用这样的调用来复制您描述的行为(SOAPAction 标头是“”):
MyPortService service = new MyPortService();
MyPort port = service.getMyPortSoap11();
MyRequest request = new MyRequest();
MyResponse response = port.subscription( request );
Run Code Online (Sandbox Code Playgroud)
以下是使用此调用的 TCP Dump 的 HTTP 标头:
POST /MyService/services HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
SOAPAction: ""
User-Agent: Apache CXF 2.7.6
Cache-Control: no-cache
Pragma: no-cache
Host: redacted
Connection: keep-alive
Content-Length: 377
Run Code Online (Sandbox Code Playgroud)
我尝试添加一个 out 拦截器并确保将 SOAPAction 设置为标头,但无论我尝试什么,都不会导致 SOAPAction 作为 HTTP 请求的一部分发送。
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass( MyPort.class );
factory.setAddress( "http://www.host.com/service" );
factory.setServiceName( new QName( targetNamespace, wsdlBindingName ) );
Object myService = factory.create();
org.apache.cxf.endpoint.Client client = ClientProxy.getClient( myService );
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("SOAPAction", Arrays.asList("mySoapAction"));
client.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
client.invoke( operationName, request );
Run Code Online (Sandbox Code Playgroud)
以下是这种风格调用的 TCP Dump 中的 HTTP 标头:
POST /MyService/services HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
SOAPAction: mySoapAction
User-Agent: Apache CXF 2.7.6
Cache-Control: no-cache
Pragma: no-cache
Host: redacted
Connection: keep-alive
Content-Length: 377
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
17199 次 |
| 最近记录: |