使用 WCF 调用 ASP.NET Web 服务时出现异常

发布于 2024-08-17 19:30:31 字数 995 浏览 4 评论 0原文

我有一个 WCF 客户端,它在另一个项目中调用 ASP.NET Web 服务。我收到以下错误消息:

System.Web.Services.Protocols.SoapException:服务器无法识别 HTTP 标头 SOAPAction 的值 http://localhost /IMyWebService/MeMethod

Web 服务代码

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService, IMyWebService
{
    [WebMethod]
    public string MyMethod() {return "";}

}

public interface IMyWebService
{
   string MyMethod();
}

WCF 客户端代码:

[ServiceContract]
public interface IMyWCFService
{
    [OperationContractAttribute(Action = "http://localhost/IMyWebService/MeMethod")]
    string MyMethod();
}

有谁知道问题是什么。

谢谢

I have a WCF client which calls an ASP.NET web service in a different project. I get the following error message:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction http://localhost/IMyWebService/MeMethod

Web Service code:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService, IMyWebService
{
    [WebMethod]
    public string MyMethod() {return "";}

}

public interface IMyWebService
{
   string MyMethod();
}

WCF client code:

[ServiceContract]
public interface IMyWCFService
{
    [OperationContractAttribute(Action = "http://localhost/IMyWebService/MeMethod")]
    string MyMethod();
}

Does anyone know what the problem is.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈独秀 2024-08-24 19:30:31

我不确定这是否是一个拼写错误,但您在客户端中使用的操作拼写为 MeMethod,而服务上的方法拼写为 MyMethod。

I'm not sure if this is a typo or not, but the action you are using in the client is spelt MeMethod, while the method on the service is spelt MyMethod.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文