我已经创建了一个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>
可以在任何一个可以帮助我解决这个错误。
看起来像你是wsdl包含远程机器名称,而不是你的机器无法解析的IP地址。考虑使用system32下的IP映射将机器名添加到您的hosts.etc中,或者将WCF服务更改为使用IP地址而不是您的计算机名称 – Rajesh
我对WCF服务非常陌生。所以你能帮我检查一下并改变你的设置。 – user2596819
上面的web.config是WCF服务还是你的.NET应用程序,你试图添加引用? – Rajesh