题
我有供应商告诉我,SOAP头不应该有HTTPS在里面,但我们仍然可以通过SSL通信。我们担心的是,我们要通过SSL和他们的示例代码导致它不发生的通信。
在他们的示例程序中,它们提供了这样的代码:
if (valservice.Url.StartsWith("https"))
{
valservice.Destination = new Microsoft.Web.Services3.Addressing.EndpointReference(
new Uri(valservice.Url.Replace("https:", "http:")));
}
从它分解成更小的步骤,并增加了一些调试,看来,当你改变了目的地,该URL自动更改。
if (valservice.Url.StartsWith("https"))
{
// fix the endpoint just in case (usually not necessary)
//original code is just this next line
//valservice.Destination = new Microsoft.Web.Services3.Addressing.EndpointReference(
// new Uri(valservice.Url.Replace("https:", "http:")));
//test code
string holdOriginalURL = valservice.Url;
Response.WriteLine("1 URL=" + valservice.Url);
Response.WriteLine("1 Destination=" + valservice.Destination);
Response.WriteLine("1 Destination.Address.Value=" + valservice.Destination.Address.Value);
Response.WriteLine("1 Destination.TransportAddress=" + valservice.Destination.TransportAddress);
//test
string newURL = valservice.Url;
newURL = newURL.Replace("https:", "http:");
//valservice.Destination = new Microsoft.Web.Services3.Addressing.EndpointReference(
// new Uri(newURL));
Microsoft.Web.Services3.Addressing.EndpointReference tempEndPoint = new Uri(newURL);
valservice.Destination = tempEndPoint;
//valservice.Url = holdOriginalURL;
Response.WriteLine("2 URL=" + valservice.Url);
Response.WriteLine("2 Destination=" + valservice.Destination);
Response.WriteLine("2 Destination.Address.Value =" + valservice.Destination.Address.Value);
Response.WriteLine("2 Destination.TransportAddress=" + valservice.Destination.TransportAddress);
}
输出:
1 URL=https://someaddress.net/orgid/SomeApplication/SomeService.asmx
1 Destination.Address.Value=https://someaddress.net/orgid/SomeApplication/SomeService.asmx
1 Destination.TransportAddress=https://someaddress.net/orgid/SomeApplication/SomeService.asmx
2 URL=http://someaddress.net/orgid/SomeApplication/SomeService.asmx
2 Destination.Address.Value=http://someaddress.net/orgid/SomeApplication/SomeService.asmx
2 Destination.TransportAddress=http://someaddress.net/orgid/SomeApplication/SomeService.asmx
<强>问题:强> 是否有可能在目的地超过网址的网址? 如果是的话怎么样?
另外,如果我重置URL更新后的目标,目标也得到改变。好像两个以某种方式相互关联,不能有什么不同?
谢谢,
尼尔沃尔特斯
更新1:一些研究表明,供应商也许能在 SoapActor属性添加到他们的网站。
当我们在URL HTTPS,他们给这个错误:
头必须匹配 Web服务的URI演员值。 演员URI值可以是明确 使用SoapActorAttribute指定 在ASMX类。在不存在的 属性,演员URI被假定为 等于的HTTP请求的URL 收到的消息。头 收载 “ https://somesite.net/orgid/SomeApp/SomeService.asmx ” 而接收器期待 “ http://somesite.net/orgid/SomeApp/SomeService.asmx ”。
解决方案
在供应商的样品确实是错误的,没有使用SSL。 解决的办法是在“VIA”参数添加到端点的构造:
valservice.Destination =
new Microsoft.Web.Services3.Addressing.EndpointReference(
new Uri(valservice.Url.Replace("https:", "http:")),
new Uri(valservice.Url));
不隶属于 StackOverflow