1

我创建了一个 WCF 服务来联系 sql 数据库。

我将服务托管在远程服务器 IIS 上。

服务已运行并且可以从 IIS 浏览。IIS Browse 返回服务 URL,如下所示。.

当我尝试从服务器外部(即我的本地系统)访问服务时,它会抛出错误。不是域名,我试过用系统IP,我可以通过IE访问服务()

当我尝试在我的 .net 应用程序上添加服务时,它会抛出错误。

来自添加服务参考的错误消息:

<!--The document was understood, but it could not be processed.
  - The WSDL document contains links that could not be resolved.
  - There was an error downloading '<!--http://sysname:4567/Service1.svc?xsd=xsd0'.
  - The remote name could not be resolved: 'sysname'
Metadata contains a reference that cannot be resolved: 'http://ipaddress:4567/Service1.svc?wsdl'.
Metadata contains a reference that cannot be resolved: 'http://ipaddress:4567/Service1.svc?wsdl'.
If the service is defined in the current solution, try building the solution and adding the service reference again.-->

Error Message From svcutil.exe:

<!--Error: Cannot obtain Metadata from http://http//ipaddress:4567/Service1.svc
?wsdl
If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess.  For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
    URI: http://http//ipaddress:4567/Service1.svc?wsdl
    Metadata contains a reference that cannot be resolved: 'http://http//ipaddres:4567/Service1.svc?wsdl'.
    There was no endpoint listening at http://http//ipaddress:4567/Service1
.svc?wsdl that could accept the message. This is often caused by an incorrect ad
dress or SOAP action. See InnerException, if present, for more details.
    The remote name could not be resolved: 'http'
HTTP GET Error
    URI: http://http//ipaddress:4567/Service1.svc?wsdl
    There was an error downloading 'http://http//ipaddress:4567/Service1.sv
c?wsdl'.
    The remote name could not be resolved: 'http'
If you would like more help, type "svcutil /?"-->

这是我的 WebConfig 文件:

<configuration> 
    <appSettings/>
    <connectionStrings/>
    <system.web>    
        <compilation debug="true">
            <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </assemblies>
        </compilation>      
        <authentication mode="Windows"/>    
        <pages>
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
        </pages>
        <httpHandlers>
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
        </httpHandlers>
        <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </httpModules>
    </system.web>
    <system.codedom>
        <compilers>
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
        </compilers>
    </system.codedom>
    <system.web.extensions>
        <scripting>
            <webServices></webServices>         
        </scripting>
    </system.web.extensions>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
            <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </handlers>
    </system.webServer>
    <system.serviceModel>
        <services>
            <service name="portalConnectorService.Service1" behaviorConfiguration="portalConnectorService.Service1Behavior">
                <host>
                  <baseAddresses>
                      <add baseAddress="http://184.73.184.213:4567/Service1.svc"></add>
                  </baseAddresses>
              </host>
                <!- - Service Endpoints - ->
                <endpoint address="" binding="wsHttpBinding" contract="portalConnectorService.IService1">                   
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="portalConnectorService.Service1Behavior">                   
                    <serviceMetadata httpGetEnabled="true"/>                    
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

谁能帮我解决这个错误。

4

1 回答 1

0

尝试注释掉指定基地址的主机部分。实际上这被 IIS 忽略了,但还是试试吧。

您收到的实际错误消息是什么?

于 2013-07-18T19:08:52.760 回答