开发者

SOAP webservice call gives null result

I am trying to get a result from a webservic开发者_Go百科e in an ASP.NET MVC (3) app. The webservice call (see below) works perfectly and I can see in Fiddler that I get a proper SOAP result back.

However, the call to "client.requestAuthorisation" results in a null. Am I missing something?

    public static string GetToken()
    {
        var token = "";
        var username = "user";
        var password = "pass";

        using (var client = new MvcApplication1.TheWebService.SingleSignOnSoapServerPortTypeClient())
        {
            using (new System.ServiceModel.OperationContextScope(client.InnerChannel))
            {
                var httpRequestProperty = new System.ServiceModel.Channels.HttpRequestMessageProperty();

                var authenticationString = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(string.Format("{0}:{1}", username, password)));
                httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = string.Format("Basic {0}", authenticationString);

                System.ServiceModel.OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] = httpRequestProperty;

                token = client.requestAuthorisation("admin");
            }
        }

        return token;
    }

The returned SOAP message is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.somedomain.ext" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:requestAuthorisationResponse>
      <return xsi:type="xsd:string">6389a2dd8da662130e6ad1997267c67b043adc21</return>
    </ns1:requestAuthorisationResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Have you tried regenerating the client code?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜