webservice.asmx中的wsdl URL错误?使用代理时的disco

时间:2015-03-16 11:16:48

标签: c# web-services

我的应用程序在Intranet中的Windows服务器上运行。应用程序URL如下所示: win_serv / APP_DIR / 。 webserwice.asmx网址是" win_serv / APP_DIR / webservice.asmx"

公共应用程序网址如下所示: app.domain.com(APP_DOMAIN),公共Webservice.asmx网址如下所示 APP_DOMAIN / webservice.asmx

在此配置中,自动生成的发现XML(APP_DOMAIN / webservice.asmx?disco)是这样的:

<?xml version="1.0" encoding="utf-8"?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
  <contractRef ref="http://APP_DOMAIN/APP_DIR/webservice.asmx?wsdl" docRef="http://APP_DOMAIN/APP_DIR/webservice.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
  <soap address="http://APP_DOMAIN/APP_DIR/webservice.asmx" xmlns:q1="http://NAMESPACE/" binding="q1:WebServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
  <soap address="http://APP_DOMAIN/APP_DIR/webservice.asmx" xmlns:q2="http://NAMESPACE/" binding="q2:WebServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>

所以我使用了类SoapExtensionReflector:

public override void ReflectDescription()
  {
     ServiceDescription description = ReflectionContext.ServiceDescription;

     foreach (Service service in description.Services)
     {
        foreach (Port port in service.Ports)
        {
           foreach (ServiceDescriptionFormatExtension extension in port.Extensions)
           {
              SoapAddressBinding binding = extension as SoapAddressBinding;

              if (null != binding)
              {
                 binding.Location = ConfigurationManager.AppSettings["SoapAddress"]; //http://APP_DOMAIN/webservice.asmx
              }
           }
        }
     }
}

但此解决方案仅修复了肥皂地址有效( http://APP_DOMAIN/webservice.asmx )。 WSDL URL仍然无效( http://APP_DOMAIN/APP_DIR/webservice.asmx?wsdl )。发现看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
  <contractRef ref="http://APP_DOMAIN/APP_DIR/webservice.asmx?wsdl" docRef="http://APP_DOMAIN/APP_DIR/webservice.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
  <soap address="http://APP_DOMAIN/webservice.asmx" xmlns:q1="http://NAMESPACE/" binding="q1:WebServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
  <soap address="http://APP_DOMAIN/webservice.asmx" xmlns:q2="http://NAMESPACE/" binding="q2:WebServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>

如何修复wsdl网址?

P.S。对不起我的英文

0 个答案:

没有答案