views:

144

answers:

1

I have a vendor telling me that the SOAP header should not have https in it, but that we can still communicate via SSL. Our concern is that we want to communicate via SSL and that their sample code is causing it not to happen.

In their sample program, they provide this code:

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

From breaking it down into smaller steps, and adding some debug, it seems that when you change the destination, that the URL automatically changes.

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);
}

Output:

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

Question: Is it possible to have a different URL in the destination than the URL? If so how?

Also, if I reset the URL after update the Destination, the Destination also gets changed. Seems like the two are somehow linked to each other and cannot be different?

Thanks,

Neal Walters

Update 1: Some research indicates that the vendor might be able to add the SoapActor attribute to their site.

When we have https in the URL, they give this error:

The header must match the actor URI value of the web service. The actor URI value can be explicitly specified using SoapActorAttribute on the ASMX class. In the absence of the attribute, the actor URI is assumed to be equal to the HTTP Request Url of the incoming message. The header received contained "https://somesite.net/orgid/SomeApp/SomeService.asmx" while the receiver is expecting "http://somesite.net/orgid/SomeApp/SomeService.asmx".

A: 

The vendor's sample was indeed wrong and not using SSL. The solution was to add the "VIA" parameter to the constructor of the endpoint:

 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

NealWalters