2013-07-18 53 views
1

我已經創建了一個WCF服務來聯繫sql數據庫。無法從c#.net應用程序訪問服務器上託管的WCF服務

我在遠程服務器IIS上承載了服務。

服務運行並且能夠從IIS瀏覽。 IIS瀏覽返回如下的服務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> 

可以在任何一個可以幫助我解決這個錯誤。

+0

看起來像你是wsdl包含遠程機器名稱,而不是你的機器無法解析的IP地址。考慮使用system32下的IP映射將機器名添加到您的hosts.etc中,或者將WCF服務更改爲使用IP地址而不是您的計算機名稱 – Rajesh

+0

我對WCF服務非常陌生。所以你能幫我檢查一下並改變你的設置。 – user2596819

+0

上面的web.config是WCF服務還是你的.NET應用程序,你試圖添加引用? – Rajesh

回答

0

嘗試註釋掉指定基地址的主機部分。 實際上這被IIS忽略,但無論如何嘗試。

你得到的實際錯誤信息是什麼?

+0

嘗試在'ipaddress:port \ service1.svc?wsdl'找到服務時發生錯誤在下面查找詳細錯誤文檔被理解,但無法處理。 - WSDL文檔包含無法解析的鏈接。 - 下載'http:// ip-0a247a29:4567/Service1.svc?xsd = xsd0'時出錯。 - 遠程名稱無法解析:'ip-0a247a29' – user2596819

+0

我已經從web.config中刪除了主機部分,但仍存在相同的問題... – user2596819

相關問題