![](/img/trans.png)
[英]System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header 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.