WSE3目标与URL

时间:2010-01-14 16:20:58

标签: c# .net web-services wse3.0

我有一个供应商告诉我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的URL? 如果是这样的话?

此外,如果我在更新目标后重置URL,则目标也会更改。好像这两个人以某种方式相互联系而且不能有所不同?

谢谢,

Neal Walters

更新1:某些研究表明供应商可能能够将 SoapActor属性添加到他们的网站。

当我们在网址中有https时,他们会出现此错误:

  

标题必须与。匹配   actor服务的URI值。   actor URI值可以是显式的   使用SoapActorAttribute指定   ASMX类。在没有的情况下   属性,假定为actor URI   等于HTTP请求URL   传入的消息。标题   收到包含   “https://somesite.net/orgid/SomeApp/SomeService.asmx”   而接收者期待   “http://somesite.net/orgid/SomeApp/SomeService.asmx”。

1 个答案:

答案 0 :(得分:0)

供应商的样本确实是错误的,并且没有使用SSL。 解决方案是将“VIA”参数添加到端点的构造函数中:

 valservice.Destination =
            new Microsoft.Web.Services3.Addressing.EndpointReference(
                new Uri(valservice.Url.Replace("https:", "http:")), 
                new Uri(valservice.Url));

http://msdn.microsoft.com/en-us/library/microsoft.web.services3.addressing.endpointreference.via.aspx