0

ASP.NET MVC (3) アプリで Web サービスから結果を取得しようとしています。Web サービス呼び出し (以下を参照) は完全に機能し、適切な SOAP 結果が返されることを Fiddler で確認できます。

ただし、「client.requestAuthorisation」の呼び出しは null になります。何か不足していますか?

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

返される SOAP メッセージは次のとおりです。

<?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>
4

1 に答える 1

0

クライアントコードを再生成してみましたか?

于 2011-07-31T21:42:11.237 に答える