问题
Hi I wonder if someone can help me, I've been banging my head against the wall trying to solve this but no luck yet :( I have a WCF hosted on IIS6 on a remote server on our internal network, http://systemservices/ServiceManagerServices.svc. I can access the service in my browser, however when trying to send a request using WcfTestClient, i get the following error:
> Error: Cannot obtain Metadata from
> http://systemservices/ServiceManagerServices.svc If this is a Windows
> (R) Communication Foundation service to which you have access, please
> check that you have enabled metadata publishing at the specified
> address. For help enabling metadata publishing, please refer to the
> MSDN documentation at
> http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
> Error URI: http://systemservices/ServiceManagerServices.svc
> Metadata contains a reference that cannot be resolved:
> 'http://systemservices/ServiceManagerServices.svc'. There was no
> endpoint listening at http://systemservices/ServiceManagerServices.svc
> that could accept the message. This is often caused by an incorrect
> address or SOAP action. See InnerException, if present, for more
> details. Unable to connect to the remote server No connection
> could be made because the target machine actively refused it
> 172.16.25.221:80HTTP GET Error URI: http://systemservices/ServiceManagerServices.svc There was an error
> downloading 'http://systemservices/ServiceManagerServices.svc'.
> Unable to connect to the remote server No connection could be made
> because the target machine actively refused it 172.16.25.221:80
I have tried changing my web.config to so many different values it is untrue, however nothing! Any ideas would be really welcome!!!
This is my web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ServiceManager.Services.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServiceManager.Services.ServiceManagerServices" behaviorConfiguration="WCFServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="ServiceManager.Services.IServiceManagerServices" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
回答1:
Since you can't connect, it could be an access restriction, but this message can show when you've been kicked back for other issues, so this could be a missing referenced binary, or use of an invalid DataContract
or something similar.
Firstly, turn on some diagnostics:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="path\to\trace.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
Now run the service, get the error and using SvcTraceTool (just go to Program Files\Microsoft SDKs
and do a search for svc
) open up the output log. This will give you more of an overview of the process, at which point it goes wrong and point to more details of the exception - sometimes just telling you to look in the Event Log for the specific exception.
回答2:
Unable to connect to the remote server No connection could be made because the target machine actively refused it 172.16.25.221:80
I would say it is a firewall issue, not a web.config issue. Can you telnet to that address on port 80 and get a response?
来源:https://stackoverflow.com/questions/9737399/wcf-hosting-issues