2011-07-31 24 views
0

ASP.NET MVC(3)アプリケーションのWebサービスから結果を取得しようとしています。 Webサービス呼び出し(下を参照)は完璧に動作し、Fiddlerでは適切なSOAP結果を返すことができます。SOAP Webサービス呼び出しでnullが返される

ただし、 "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> 

答えて

0

あなたは、クライアントコードを再生成しようとしたことがありますか?

関連する問題