[英]“SoapException: Server did not recognize the value of HTTP Header SOAPAction” when programmatically defining Binding instead of App.Config
I have an asmx web service. 我有一个asmx Web服务。 On the client side, I don't want to use app config.
在客户端,我不想使用应用程序配置。 So I am trying to read the configuration of my application using a ChannelFactory service.:
因此,我试图使用ChannelFactory服务读取应用程序的配置。
BasicHttpBinding myBinding = new BasicHttpBinding();
And set all the attributes from my app.config. 并从我的app.config中设置所有属性。 Then I have defined my endpoint and channel factory:
然后,我定义了端点和通道工厂:
EndpointAddress myendpoint = new EndpointAddress("http://localhost:<portNumber>/<serviceName>.asmx");
ChannelFactory<IServiceInterface> myCh = new ChannelFactory<IServiceInterface>(myBinding, myendpoint);
IServiceInterface service = myCh.CreateChannel();
This is the error I get when calling a method from my channel: 这是从通道调用方法时遇到的错误:
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
One of the things you can do is to change Action property in OperationContract attribute in your service's interface. 您可以做的一件事是在服务界面中的OperationContract属性中更改Action属性。
[ServiceContract]
interface IService
{
[OperationContract(Action = "http://tempuri.org/GetString")]
string GetString();
}
I am not sure this is the best solution, searching for another one and will prompt if find anything. 我不确定这是否是最好的解决方案,正在寻找另一种解决方案,并会提示是否找到任何东西。 But this one works for me.
但这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.