簡體   English   中英

通過編程方式定義綁定而不是App.Config時出現“ SoapException:服務器無法識別HTTP標頭SOAPAction的值”

[英]“SoapException: Server did not recognize the value of HTTP Header SOAPAction” when programmatically defining Binding instead of App.Config

我有一個asmx Web服務。 在客戶端,我不想使用應用程序配置。 因此,我試圖使用ChannelFactory服務讀取應用程序的配置。

 BasicHttpBinding myBinding = new BasicHttpBinding();

並從我的app.config中設置所有屬性。 然后,我定義了端點和通道工廠:

EndpointAddress myendpoint = new EndpointAddress("http://localhost:<portNumber>/<serviceName>.asmx");
ChannelFactory<IServiceInterface> myCh = new ChannelFactory<IServiceInterface>(myBinding, myendpoint);
IServiceInterface service = myCh.CreateChannel();

這是從通道調用方法時遇到的錯誤:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header     SOAPAction: http://localhost/<serviceName.asmx/IServiceInterface/<MethodName>.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest

您可以做的一件事是在服務界面中的OperationContract屬性中更改Action屬性。

[ServiceContract]
interface IService
{
    [OperationContract(Action = "http://tempuri.org/GetString")]
    string GetString();
}

我不確定這是否是最好的解決方案,正在尋找另一種解決方案,並會提示是否找到任何東西。 但這對我有用。

暫無
暫無

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

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