簡體   English   中英

SOAP HTTPS服務在C#中使用

[英]SOAP HTTPS Services consume in c#

我正在嘗試使用HTTPS SOAP服務,該服務具有對其進行授權的憑據並得到以下錯誤:

mscorlib.dll中發生了類型為'System.ServiceModel.ProtocolException'的未處理異常

附加信息:內容類型為text / html; 響應消息的charset = utf-8與綁定的內容類型不匹配(text / xml; charset = utf-8)。 如果使用自定義編碼器,請確保正確實施IsContentTypeSupported方法。 響應的前1024個字節為:'

綁定如下。 我有什么想念的嗎?

<endpoint address="https://...."
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInboundService1"
          contract="RQSInboundExternal.IInboundService" name="BasicHttpBinding_IInboundServiceQSPort">

<basicHttpBinding>              
            <binding name="BasicHttpBinding_IInboundService1" >                  
              <security mode="Transport" >
               <transport clientCredentialType="Basic"/>                   
              </security>
            </binding>
        </basicHttpBinding>

在此處設置用戶名和密碼。 這也需要發送。 如果我們僅發送標題,則它不起作用。

client.ClientCredentials.UserName.UserName = "";
client.ClientCredentials.UserName.Password = "";

var httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName + ":" + client.ClientCredentials.UserName.Password));
            client.Open();
            var context = new OperationContext(client.InnerChannel);
            using (new OperationContextScope(context))
            {
                context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

                client.SampleMethodCall();
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM