且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WCF托管问题

更新时间:2023-02-26 19:24:07

既然您无法连接,它可能是一个访问限制,但此消息可以显示当你被人踢回等问题,所以这可能是一个缺少引用的二进制文件,或无效 DataContract 或类似的东西的使用



首先,打开一些诊断:

 <系统.diagnostics&GT; 
&LT;来源和GT;
<信源名称=System.ServiceModelswitchValue =警告,ActivityTracingpropagateActivity =真&GT;
&LT;&听众GT;
&LT;加上TYPE =System.Diagnostics.DefaultTraceListenerNAME =默认&GT;
&LT;滤波器类型=/&GT;
&LT; /添加>
&LT;添加名称=ServiceModelTraceListener&GT;
&LT;滤波器类型=/&GT;
&LT; /添加>
&LT; /听众&GT;
&LT; /源&GT;
&LT; /来源&GT;
&LT; sharedListeners&GT;
&LT;添加initializeData =path\to\trace.svclog
型=System.Diagnostics.XmlWriterTraceListener,系统,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089
产品名称=ServiceModelTraceListenertraceOutputOptions =时间戳&GT;
&LT;滤波器类型=/&GT;
&LT; /添加>
&LT; / sharedListeners&GT;





现在运行的服务,得到错误和使用 SvcTraceTool (只要到计划Files\Microsoft的SDK 并做 SVC )打开输出日志搜索。这会给你更多的过程的概述,此时它出错并指向异常的详细信息 - 有时只是告诉你在事件日志中查找特定异常


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>

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.