2

我正在尝试在远程服务器上使用 WCF 服务。我可以浏览到服务(它的位置格式为http://IntranetServerName:40000/VirtualDirectoryName/ServiceName.svc),所以我可以很好地浏览到远程位置。

然后我(按照页面的指示)http://IntranetServerName:40000/VirtualDirectoryName/ServiceName.svc?wsdl在命令行中运行 svcutil.exe。

生成了一个客户端,但配置文件似乎已将端点从远程位置转换为 localhost,并假定它是一个命名管道(它不是)。

我认为网络中的某个地方(防火墙等)存在问题,但我与之交谈的网络人员说他们可以看到流量,这是一个应用程序问题。

所以首先,我想了解是什么原因导致 svcutil 在代理远程服务器时建议使用 netNamedPipeBinding?如果我理解它可能会为我遇到的后续问题提供线索。

我无权访问远程服务器的文件系统。我在 Windows 7 64 位上使用 VS2010。这是配置文件:

<configuration>
    <system.serviceModel>
        <bindings>
            <netNamedPipeBinding>
                <binding name="ServiceNameNamedPipeEndPoint" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                    maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport protectionLevel="EncryptAndSign" />
                    </security>
                </binding>
            </netNamedPipeBinding>
        </bindings>
        <client>
            <endpoint address="net.pipe://localhost/VirtualDirectoryName/ServiceName.svc"
                binding="netNamedPipeBinding" bindingConfiguration="ServiceNameNamedPipeEndPoint"
                contract="ServiceNameContract" name="ServiceNameNamedPipeEndPoint" />
        </client>
    </system.serviceModel>
</configuration>

谢谢。

更新

我一直在查看 WSDL,我发现了这一点:

<wsdl:service name="ServiceName">
 <wsdl:port name="ServiceNameNamedPipeEndPoint" binding="i0:ServiceNameNamedPipeEndPoint">
  <soap12:address location="net.pipe://localhost/VirtualDirectoryName/ServiceName.svc"/>
   <wsa10:EndpointReference>
    <wsa10:Address>
net.pipe://localhost/VirtualDirectoryName/ServiceName.svc
   </wsa10:Address>
  </wsa10:EndpointReference>
 </wsdl:port>
</wsdl:service>

在我看来,指定命名管道是要使用的绑定。这听起来合理吗?如果是这样,有人可以建议是什么操作或设置导致将其添加到 WSDL 中吗?

更新 (2)

这是服务的配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="Logging" value="True" />
    <add key="LogPath" value="c:\Temp\" />
  </appSettings>
  <connectionStrings>
    <add name="MyAppConnectionString" connectionString="Data Source=ReportingServerName\MyApp_UAT;Initial Catalog=MyApp;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="UnityBehaviorExtension" type="MyDomain.MyApp.Business.Services.Implementations.UnityEndPointBehaviour, MyDomain.MyApp.Business.Services.Libs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cf929a8c65660387" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <netNamedPipeBinding>
        <binding name="NamedPipeBinding" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="02:00:00">
          <security mode="None">
            <transport protectionLevel="None" />
          </security>
        </binding>
      </netNamedPipeBinding>
      <netTcpBinding>
        <binding name="NetTcpBinding_MyReportsService" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="6553600" maxConnections="10" maxReceivedMessageSize="6553600">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IReportGeneratorService" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_PackageTriggerServiceContract" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IReportGeneratorService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
        <binding name="MetadataExchangeHttpBinding_IReportGeneratorService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://IntranetServerName:41000/MyDomain.MyApp.Reports.Services.WebHost/MyDomain.MyApp.Reports.Services.Hosts.ReportGeneratorServiceHost.svc/mex" binding="wsHttpBinding" bindingConfiguration="MetadataExchangeHttpBinding_IReportGeneratorService" contract="SvcReference.IReportGeneratorService" name="MetadataExchangeHttpBinding_IReportGeneratorService" />
      <endpoint address="http://IntranetServerName:41000/MyDomain.MyApp.Reports.Services.WebHost/MyDomain.MyApp.Reports.Services.Hosts.ReportGeneratorServiceHost.svc/basic" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReportGeneratorService" contract="SvcReference.IReportGeneratorService" name="BasicHttpBinding_IReportGeneratorService" />
      <endpoint address="http://ReportingServerName:42500/MyDomain.MyApp.Integration.Services.PackageTriggerService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PackageTriggerServiceContract" contract="PackageTriggerService.PackageTriggerServiceContract" name="BasicHttpBinding_PackageTriggerServiceContract" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="UnityBehaviorExtension">
          <UnityBehaviorExtension />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.REPS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.SRefS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.MyReportsInterfaceService_behaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.DFS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.ServiceName_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementation.FCS_Behaviour">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementation.FCS2_Behaviour">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.BIS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.CS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.W2CS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>
        <behavior name="MyDomain.MyApp.Business.Services.Implementations.TrS_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.REPS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.REPS">
        <clear />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="REPSMexEndPoint" contract="IMetadataExchange" listenUriMode="Explicit" />
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/REPS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="REPSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IREPSContract" listenUriMode="Explicit" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.W2CS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.W2CS">
        <clear />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="W2CSMexEndPoint" contract="IMetadataExchange" listenUriMode="Explicit" />
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/W2CS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="W2CSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IW2CSContract" listenUriMode="Explicit" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.SRefS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.SRefS">
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="SRefSMexEndPoint" contract="IMetadataExchange" />
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/SRefS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="SRefSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.ISRefSContract" listenUriMode="Explicit" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.MyReportsInterfaceService_behaviour" name="MyDomain.MyApp.Business.Services.Implementations.MyReportsService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_MyReportsService" name="MyReportsServiceNetTcpEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IMyReportsServiceContract" />
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="MyReportsServiceMexTcpBindingEndpoint" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:50000/" />
          </baseAddresses>
        </host>
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.DFS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.DFS">
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="DFSMexEndPoint" contract="IMetadataExchange" />
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/DFS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="DFSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IDFSContract" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.ServiceName_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.ServiceName">
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="ServiceNameMexEndPoint" contract="IMetadataExchange" />
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/ServiceName.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="ServiceNameNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IServiceNameContract" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementation.FCS_Behaviour" name="MyDomain.MyApp.Business.Services.Implementations.FCS">
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/FCS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="FCSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IFCSContract" />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="FixedContractMexEndPoint" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementation.FCS2_Behaviour" name="MyDomain.MyApp.Business.Services.Implementations.FCS2">
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/FCS2.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="FCS2NamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IFCS2Contract" />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="FlexContractMexEndPoint" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.BIS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.BIS">
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/BIS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="BISNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IBISContract" />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="BISMexEndPoint" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.CS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.CS">
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/CS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="CSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.ICSContract" />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="CSMexEndPoint" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="MyDomain.MyApp.Business.Services.Implementations.TrS_Behavior" name="MyDomain.MyApp.Business.Services.Implementations.TrS">
        <endpoint address="net.pipe://localhost/MyDomain.MyApp.Business.Services.WebHost/TrS.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="TrSNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.ContractA" />
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="TrSMexEndPoint" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="OptionInfer" value="true" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <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" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" 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" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </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.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <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" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing, Verbose" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

我现在还可以访问托管该服务的服务器。它是 IIS 6.1。

在网站的高级设置中,启用的协议设置为“http,net.pipe,net.tcp,net.msmq”。我没想到会在该列表中看到“http”,所以我仍然对为什么 svcutil 只会生成命名管道绑定感到困惑。我想要的是一个可以远程使用的绑定。你能看到我应该改变什么来允许这个吗?

谢谢。

4

2 回答 2

2

我现在已经弄清楚了。

<services>服务配置的元素中,我添加了一个新endpoint元素:

 <service>
    <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" name="ServiceNameMexEndPoint" contract="IMetadataExchange" />
    <endpoint address="net.pipe://localhost/VirtualDirectoryName/ServiceName.svc" behaviorConfiguration="UnityBehaviorExtension" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="ServiceNameNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IServiceNameContract" />
    <!-- 20/06/2012 added this to let svcutil benerate a non-named pipe binding START-->
        <endpoint address="http://sluat01lonuk.gazpromuk.intra:40000/VirtualDirectoryName/ServiceName.svc" behaviorConfiguration="UnityBehaviorExtension" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceName" name="ServiceNameNamedPipeEndPoint" contract="MyDomain.MyApp.Business.Services.Contracts.IServiceNameContract" />
        <!-- 20/06/2012 added this to let svcutil benerate a non-named pipe binding END-->
  </service>

svcutil 仅生成命名管道连接的原因是没有公开的替代端点。

一旦我对服务进行了此更改,WSDL 就会更新以保存新的端点。然后重新运行 svcutil 导致 basicHttpBinding 绑定被添加到 output.config。

所以要完整而明确地回答我的问题:是什么导致 svcutil 在代理远程服务器时建议使用 netNamedPipeBinding 是因为<services>服务配置中的元素仅包含 net.pipeendpoint而不是 http(或者,我猜是 net.tcp)端点。

希望这可以帮助某人。

谢谢。

于 2012-06-20T15:17:31.727 回答
1

ABC 的 WCF 服务有 3 件事

A - 地址 - 在 wsdl:service 部分中表示,并将 wsdl:binding 链接到具体的服务端点地址

B - 绑定 - 如 wsdl:binding 部分所述,并将 wsdl:portType 合同描述绑定到具体传输、信封格式和相关策略

C - 契约 - 在 wsdl:portType、wsdl:message 和 wsdl:type 部分中表达,并描述类型、消息、消息交换模式和操作

您发布的 WSDL 中的服务部分清楚地指出,该服务已暴露给 netNamedPipeBinding。

但我不明白,为什么它可以通过 HTTP 协议访问(http://IntranetServerName:40000/VirtualDirectoryName/ServiceName.svc?wsdl)

你有没有机会看看你的服务的配置文件?

于 2012-06-19T16:19:32.110 回答