我使用 wsimport (JDK 1.7) 生成了一个 SOAP 1.2 Web 服务客户端。我需要它来明确使用 WS-Addressing 2004/08 而不是 2005/08。我能找到的最接近客户的实例是
import MyService.*;
import javax.xml.ws.BindingProvider;
public class test {
public static void main(String[] args) {
MyService service = new MyService();
IMyService proxy = service.getMyService(new javax.xml.ws.soap.AddressingFeature(true, true) );
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://192.168.0.5:1234/services/MyService");
proxy.Ping("Foo");
}
}
重要的一点是
MyService service = new MyService();
IMyService proxy = service.getMyService(new javax.xml.ws.soap.AddressingFeature(true, true));
不幸的是,这导致了 2005/08 寻址。不向 getMyService() 提供参数会导致不使用 WS-Addressing。
我可以在 Google 上找到的唯一示例强制 2004/08 寻址使用 Axis2(我想要 JAX-WS 的全部原因是远离 Axis2)
电线上的区别是(2004/08)
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.example.com/schemas/service/myservice/IMyService/Ping</a:Action>
<a:MessageID>urn:uuid:87727401-b1a0-4667-9ef0-c64e58800ff6</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://192.168.0.5:1234/services/MyService</a:To>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Ping xmlns="http://www.example.com/schemas/service/myservice">
<Message>Foo</Message>
</Ping>
</s:Body>
</s:Envelope>
(2005/08)
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">https://192.168.0.5:1234/services/MyService</To>
<Action xmlns="http://www.w3.org/2005/08/addressing" xmlns:S="http://www.w3.org/2003/05/soap-envelope" S:mustUnderstand="true">http://www.example.com/schemas/service/myservice/IMyService/Ping</Action>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:87727401-b1a0-4667-9ef0-c64e58800ff6</MessageID>
</S:Header>
<S:Body>
<Ping xmlns="http://www.example.com/schemas/service/myservice">
<Message>Foo</Message>
</Ping>
</S:Body>
</S:Envelope>
有人在这里有什么想法吗?