Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 动态web服务URL的问题_C#_Sql Server_Web Services_Service - Fatal编程技术网

C# 动态web服务URL的问题

C# 动态web服务URL的问题,c#,sql-server,web-services,service,C#,Sql Server,Web Services,Service,我有一个用于调用多个web服务的服务,每个web服务都有一个DEV、TST和PRD等价物。目前,我一直在制作一个web服务实例,然后交换URL的一些部分,以便根据需要在不同环境之间进行更改 我设法使其正常工作,但最近我更改了代码,使用数据库包含不同环境中相同服务的不同URL,但是URL现在导致调用出现问题,我收到以下错误消息: System.Web.Services.Protocols.SoapException: Possible SOAP version mismatch: Envelope

我有一个用于调用多个web服务的服务,每个web服务都有一个DEV、TST和PRD等价物。目前,我一直在制作一个web服务实例,然后交换URL的一些部分,以便根据需要在不同环境之间进行更改

我设法使其正常工作,但最近我更改了代码,使用数据库包含不同环境中相同服务的不同URL,但是URL现在导致调用出现问题,我收到以下错误消息:

System.Web.Services.Protocols.SoapException: Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at VRLSAPData.web.vrl.InvoiceList.ZB2B_WS_FUNCTIONS_006_SRV.ZB2bCustomerInvoiceList(ZB2bCustomerInvoiceList ZB2bCustomerInvoiceList1) in c:\Users\pigramm\Testing\VS 2010 Projects\VRLSAPData\VRLSAPData\Web References\web.vrl.InvoiceList\Reference.cs:line 81
   at VRLSAPData.SAPAllInvoices.AllInvoices(String environment, String companyNumber, String customerNumber, String dateFrom, String dateTo) in c:\Users\pigramm\Testing\VS 2010 Projects\VRLSAPData\VRLSAPData\SAPAllInvoices.cs:line 31
我打电话的代码如下:

public static web.vrl.InvoiceList.ZB2B_WS_FUNCTIONS_006_SRV ConnectToSapAllInvoicesService(string environment = "tst")
{
        var sapInvoiceListProxy = new web.vrl.InvoiceList.ZB2B_WS_FUNCTIONS_006_SRV();

        sapInvoiceListProxy.AllowAutoRedirect = true;
        sapInvoiceListProxy.Url = GetServiceURL(environment, "AllInvoices");

        sapInvoiceListProxy.Timeout = 900000;
        sapInvoiceListProxy.Credentials = sapLogin;

        return sapInvoiceListProxy;
 }
GetServiceURL()
根据传递给数据库的名称和环境从数据库中获取URL,我已检查,返回的结果与预期一致


我已经试过调试代码,但没有发现任何错误,URL似乎是正确的,当复制到web浏览器中时,工作正常。有人知道这里出了什么问题吗?

请检查以下链接

从上述链接中删除。也许这会有帮助

问题是您正在将webservice的URL属性设置为WSDL URL。您需要将webservice实例的URL设置为webservice本身的位置,这是包含在WSDL中的内容。要查找此URL,请在文本编辑器中打开WSDL文档并查找元素的“location”属性。您可以也应该在VisualStudio中使用图形工具的WSDL url,但在运行时进行区分很重要


问题似乎与您在上面所述的一样,但是我觉得这可以更好地向其他人解释,通过添加一个web服务并比较其在
sapinovicelistproxy.URL
之前出现的URL,我能够找到正确的URL