如何在不重新生成客户端代码的情况下更改服务引用的端点?

时间:2014-11-11 18:36:12

标签: c# web-services wcf soap

我们正在集成第三方SOAP API。我们已经针对此API的开发版本进行了开发。现在我们要切换到生产版本。如何在不重新生成针对新端点URL的整个服务引用的情况下执行此操作?在一个完美的世界中,我们只能将配置文件中的路径更改为指向新端点,但由于名称空间问题,这似乎不起作用。

在配置中(或以编程方式)更改端点地址时,此错误在运行时发生:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://foo.bar.com/DEVWebService/AuthenticateUser. 
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
  at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

我认为这是因为自动生成的引用类具有以下的SOAP动作:

[System.ServiceModel.OperationContractAttribute(Action="http://foo.bar.com/DEVWebService/AuthenticateUser", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Data.DataSet AuthenticateUser(string strSecurityKey, string strUsername, string strPassword);

通过配置轻松更改端点URL的最佳方法是什么,而不是重建服务引用的所有代码?

0 个答案:

没有答案
相关问题