我刚刚开始使用SOAP Web服务,偶然发现了WS-Addressing.
我已阅读维基百科页面,但我很难理解WS-Addressing的重点.
根据维基百科和Web上的各种来源,WS-Addressing允许将"寻址信息"或"路由信息"放入SOAP请求的标头中.
为什么这有用?如果我通过HTTP(或甚至通过SMTP或UDP)发送请求,那么我发送到的地址是将处理我的请求的服务器的地址,并且服务器可以简单地通过相同的通道进行回复.那么为什么需要寻址/路由信息呢?
我对一些真实世界(或多或少)WS-Addressing有用的例子特别感兴趣.
嗨,我创建消费SOAP服务的代码,
对于Authentication Header,我使用Wss4jSecurityInterceptor来设置Header信息.
我收到如下的失败回应
Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Required element {http://www.w3.org/2005/08/addressing}Action is missing
Run Code Online (Sandbox Code Playgroud)
我的配置代码如下
@Configuration
public class SoapClientConfig {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.xyz.client");
marshaller.setCheckForXmlRootElement(false);
return marshaller;
}
@Bean
public MyClient myClient(Jaxb2Marshaller marshaller) throws Exception {
MyClient client = new MyClient();
client.setDefaultUri("https://localhost:8080/ws/service");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
ClientInterceptor[] interceptors = new ClientInterceptor[] {securityInterceptor()};
client.setInterceptors(interceptors);
return client;
}
@Bean
public Wss4jSecurityInterceptor securityInterceptor() {
Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();
wss4jSecurityInterceptor.setSecurementActions("UsernameToken");
wss4jSecurityInterceptor.setSecurementMustUnderstand(true);
wss4jSecurityInterceptor.setSecurementPasswordType("PasswordText");
wss4jSecurityInterceptor.setSecurementUsername("XXXXXXXXXXX");
wss4jSecurityInterceptor.setSecurementPassword("XXXXXXXX");
return wss4jSecurityInterceptor;
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用WCF调用BizTalk服务.该服务要求在SOAP标头中设置wsa:replyto地址,以便在完成该过程时进行"回调".
我们正在使用合同优先的approch来自svcutil的自动生成代码(我们不能'只是'改变合同)......
并且在配置文件中不可能...
我看到有人'覆盖'某些方法来制作自己的自定义标头 - 但这不是自定义标头,而是SOAP协议中的标准.
如何在(SOAP)标头中添加wsa:replyto?
所有,我正在尝试编写一个在Axis2.1.5中调用Web服务客户端的Junit测试,并且我对如何将其设置为使用WS-Addressing感到困惑.
我使用wsdl2java生成了一个客户端存根,我正在使用来自axis2二进制分发的axis2.xml和modules存储库.
我知道我需要使用的WS-Addressing的MemberSubmission版本,我想我已经得到了正确设置(使用选项),但似乎是头不得到正确生成.(我说'似乎'因为我无法弄清楚如何使用SOAPMonitor模块 - 我也欢迎任何提示!).
然而,我的主要困惑在于"参与"寻址模块究竟需要什么.是否足以使用具有对寻址模块的引用的axis2.xml文件来设置ConfigurationContext?像这样?:
//standard out of the box axis2 configs
ConfigurationContext myConfigContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem("C:/devapps/axis2-1.5.1/repository","C:/devapps/axis2-1.5.1/conf/axis2.xml");
Options options = new Options();
EndpointReference targetEPR = new EndpointReference(
"https://host:port/service.asmx");
options.setTo(targetEPR);
//I believe this is what I'm supposed to do to specify the
//MemberSubmission version of WS-Addressing
options.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
AddressingConstants.Submission.WSA_NAMESPACE);
//No idea of this is needed or not.
options.setProperty(AddressingConstants.INCLUDE_OPTIONAL_HEADERS,
Boolean.TRUE);
options.activate(myConfigContext);
options.setAction("someAction");
CaseDetailsServiceStub stub = new CaseDetailsServiceStub(
"https://host:port/service.asmx");
stub._getServiceClient().setOptions(options);
//I'm calling this from a Junit test
assertNotNull(stub.someAction(someParam));
Run Code Online (Sandbox Code Playgroud)
使用上面设置的选项,在日志文件中看到模块从axis2.xml加载:
[INFO] Deploying …Run Code Online (Sandbox Code Playgroud) 我只是对ws-addressing感到困惑.
维基百科称,它是一种传输中立机制的规范,允许Web服务"传递寻址信息".
沟通寻址信息?SOAP Web服务是否已具备开始时的能力,否则它们将如何进行通信?
鉴于它似乎提供核心功能,它给出了什么价值,为什么不是默认的东西的一部分?
我有一个Delphi企业应用程序,它充当Java后端(SOAP,Axis2)的客户端.我的一些请求需要不确定或特别大的时间才能完成,我想为SOAP请求实现一个长轮询解决方案.
据我所知,我通常会使用WS-Addressing.但是,似乎Delphi SOAP客户端(WCF)没有实现WS-Addressing.
我被锁定在Java和Delphi中.我使用Axis 2组件,例如生命周期,但我可以转换到另一个Web服务引擎.我控制服务器和客户端.
在Delphi和Java中实现长轮询有哪些选择?
有人可以解释为什么我会在 spring-ws 中使用这些端点注释之一而不是另一个吗?特别是,哪一个被认为最具包容性?我可以同时使用这三个吗?我已阅读该文档,并且知道 @Action 使用 ws-addressing 而 @SoapAction 使用 SOAP Action 传输标头,但我不太确定哪个更适合使用。
谢谢。
我在互联网托管服务提供商中部署了一个Web应用程序.此Web应用程序使用部署在我公司应用程序服务器的IIS服务器上的WCF服务,以便能够访问公司的数据库,网络人员允许我出于安全原因通过防火墙公开此WCF服务.图表看起来像这样.
[主页] --->(Internet)---> |防火墙
<Public IP>:<Port-X >| ---> [带WCF服务的IIS<Comp. Network Ip>:<Port-Y>]
我还想使用wsHttpBinding来利用其安全功能,并加密敏感信息.
尝试后,我收到以下错误:
异常详细信息:System.ServiceModel.EndpointNotFoundException:由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理带有To'http://:/service/WCFService.svc'的消息.检查发送方和接收方的EndpointAddresses是否一致.
做一些研究我发现wsHttpBinding使用WS-Addressing标准,并且阅读了这个标准,我了解到SOAP标头已经增强,包括'MessageID','ReplyTo','Action'和'To'等标签.
所以我猜测,因为客户端应用程序端点指定防火墙IP地址和端口,并且服务使用与防火墙IP不同的内部网络地址进行回复,然后WS-Addressing将触发上述消息.我认为这是一个非常好的安全措施,但在我的方案中它并不是很有用.
引用WS-Addressing标准提交(http://www.w3.org/Submission/ws-addressing/)
"由于目前广泛使用的网络技术范围广泛(例如,NAT,DHCP,防火墙),许多部署无法为给定端点分配有意义的全局URI.允许这些"匿名"端点启动消息交换模式和接收回复时,WS-Addressing定义了以下众所周知的URI,供不能具有稳定,可解析的URI的端点使用 .http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous "
我如何配置我的wsHttpBinding端点来解决我的防火墙的IP并忽略或绕过SOAP消息头中"To"WS-Addressing标记中指定的地址?或者我是否必须在服务端点配置中更改某些内容?
非常感谢帮助和指导.
马尔科.
PS:虽然我找到了解决方法,但我当然使用basicHttpBinding完全没问题.
我正在尝试使用 Apache CXF 2.7.18 实现 WS-Addressing。我可以设置一些标题,如 To、Action 等。但我想从 SOAP 请求中删除/删除 ReplyTo
<Action xmlns="http://www.w3.org/2005/08/addressing">http://...</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:....</MessageID>
<To xmlns="http://www.w3.org/2005/08/addressing">https://....</To>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做吗?
我使用 spring-boot-starter-webservices 使用 spring 创建了一个 ws 端点。
我用过@org.springframework.ws.server.endpoint.annotation.Endpoint,效果很好。
但是当我尝试将寻址标头添加到带有服务器打印的wsa:ReplyTo请求时:mustUnderstand=true
无法处理 MustUnderstand 标头:{http://www.w3.org/2005/08/addressing}ReplyTo。返回故障
并返回类似的故障作为响应。
如何启用寻址以便ReplyTo被理解并回复202,将响应发送到中描述的不同端点ReplyTo?
我尝试添加@javax.xml.ws.soap.Addressing(enabled=true)旁边的@Endpoint注释,但我仍然得到上述行为。
我有一个问题:我们正在尝试使用Apache CXF实现WS-Addressing.我可以设置一些像To或Action这样的标题,但我找不到设置其他像From,ReplyTo或FaultTo的方法.
有谁知道怎么做?
我正在尝试通过 SOAP 消息(我已提取)发送到我的 WCF 服务,而不使用 WCF 客户端基础结构。在不使用我的生产消息(和代码)的情况下,我已经能够设置同一问题的虚拟版本(感谢 WF_WCF_Samples)。
所以合同看起来像这样:
[ServiceContract(Namespace="http://Microsoft.Samples.UsingUsing")]
public interface ICalculator
{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
}
Run Code Online (Sandbox Code Playgroud)
查看实际 WCF 客户端发送的 SOAP 消息,我在 WCF 跟踪中得到以下信息:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:56852/service.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://Microsoft.Samples.UsingUsing/ICalculator/Divide</Action>
</s:Header>
<s:Body>
<Divide xmlns="http://Microsoft.Samples.UsingUsing">
<n1>0</n1>
<n2>0</n2>
</Divide>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是工作电话中的内容。但是,如果我尝试执行此操作,则会收到记录在 WCF 跟踪中的以下异常:
寻址版本“AddressingNone ( http://schemas.microsoft.com/ws/2005/05/addressing/none )”不支持添加 WS-Addressing 标头。
我尝试过使用 SoapUI 甚至 Httpie 来发送 XML 文件: …
ws-addressing ×12
soap ×7
java ×5
wcf ×3
web-services ×3
cxf ×2
jax-ws ×2
axis2 ×1
c#-4.0 ×1
delphi ×1
delphi-xe2 ×1
firewall ×1
soap-client ×1
spring ×1
spring-boot ×1
spring-ws ×1
xml ×1