使用netNamedPipeBinding在Windows服务中使用wcf [英] wcf in windows service with netNamedPipeBinding

查看:64
本文介绍了使用netNamedPipeBinding在Windows服务中使用wcf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用NetnamedPipe在Windows服务中托管WCF SOAP。无论我尝试什么,客户端似乎都没有找到服务...

I'm trying to host WCF SOAP in Windows service using NetnamedPipe. no matter what i try the client doesn't seem to find the service...

使用命令promt svcutil: 

when using command promt svcutil: 

SvcUtil。 exe / language:cs /out:generatedProxy.cs /config:app.config net.pipe:// localhost / SoapCommunication / SoapCommunication / mex

SvcUtil.exe /language:cs /out:generatedProxy.cs /config:app.config net.pipe://localhost/SoapCommunication/SoapCommunication/mex

我收到以下错误: 

i get the following error: 

如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布。 有关启用元数据发布的帮助,请参阅MSDN文档,网址为http://go.microsoft.com/fwlink/?LinkId=65455。




WS-Metadata Exchange错误

    URI:net.pipe:// localhost / SoapCommunication / SoapCommunication / mex



   元数据包含无法解析的引用:'net.pipe:// localhost / SoapCommunication / SoapCommunication / mex'。
$


   发送到net.pipe:// localhost / SoapCommunication / SoapCommunication / mex的请求操作未在配置的超时(00:05:00)内收到回复。 分配给此操作的时间可能是较长超时的一部分。 
这可能是因为该服务仍在处理该操作,或者因为该服务无法发送回复消息。 请考虑增加操作超时(通过将频道/代理转换为IContextChannel并设置OperationTimeout
属性)并确保该服务能够连接到客户端。

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: net.pipe://localhost/SoapCommunication/SoapCommunication/mex

    Metadata contains a reference that cannot be resolved: 'net.pipe://localhost/SoapCommunication/SoapCommunication/mex'.

    This request operation sent to net.pipe://localhost/SoapCommunication/SoapCommunication/mex did not receive a reply within the configured timeout (00:05:00).  The time allotted to this operation may have been a portion of a longer timeout.  This may be because the service is still processing the operation or because the service was unable to send a reply message.  Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.

之后漫游互联网超过两天这是我的最后一招...

after roaming the internet for more than a couple of days this is my last resort...

代码如下

interface:

interface:

  [ServiceContract]

   接口ISoapCommunication

    {

        [OperationContract]

        string GetDate();

    }

 [ServiceContract]
    interface ISoapCommunication
    {
        [OperationContract]
        string GetDate();
    }

class:

[ServiceBehavior(UseSynchronizationContext = false,ConcurrencyMode = ConcurrencyMode.Single,InstanceContextMode = InstanceContextMode.Single)]
$
   公共课SoapCommunication:ISoapCommunication

    {

       公共字符串GetDate()

        {

           返回"日期是" + DateTime.Now.ToString();

        }¥b $ b    }

[ServiceBehavior(UseSynchronizationContext = false, ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)]
    public class SoapCommunication:ISoapCommunication
    {
        public string GetDate()
        {
            return "Date is " + DateTime.Now.ToString();
        }
    }

web.config:

web.config:

< configuration>

&NBSP; < startup>

  &NBSP; < supportedRuntime version =" v4.0" SKU = QUOT; .NETFramework,版本= v4.5.2" />

  < / startup>

  < system.serviceModel>

  &NBSP; < services>

  &NBSP; &NBSP; < service name =" MyWCFWinSrv.SoapCommunication" behaviorConfiguration =" ServiceBehavior">

  &NBSP; &NBSP; &NBSP; < host>

  &NBSP; &NBSP; &NBSP; &NBSP; < baseAddresses>

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < add baseAddress =" net.pipe:// localhost / SoapCommunication" />

  &NBSP; &NBSP; &NBSP; &NBSP; < / baseAddresses>

  &NBSP; &NBSP; &NBSP; < / host>

  &NBSP; &NBSP; &NBSP; < endpoint address =" SoapCommunication"结合= QUOT; netNamedPipeBinding" contract =" MyWCFWinSrv.ISoapCommunication" />

  &NBSP; &NBSP; &NBSP; < endpoint address =" SoapCommunication / mex"结合= QUOT; mexNamedPipeBinding" contract =" IMetadataExchange" />

  &NBSP; &NBSP; < / service>

  &NBSP; < / services>

  &NBSP; < bindings>

  &NBSP; &NBSP; < basicHttpBinding>

  &NBSP; &NBSP; &NBSP; < binding name =" basicHttpBindingClient" transferMode = QUOT;串流" messageEncoding = QUOT; MTOM" maxReceivedMessageSize = QUOT; 10067108864" maxBufferPoolSize = QUOT; 2147483647" MAXBUFFERSIZE = QUOT; 2147483647"
closeTimeout =" 01:00:00" openTimeout = QUOT; 01:00:00" receiveTimeout = QUOT; 01:00:00" sendTimeout =" 01:00:00">

  &NBSP; &NBSP; &NBSP; &NBSP; < readerQuotas maxDepth =" 2147483647" maxStringContentLength = QUOT; 2147483647"的MaxArrayLength = QUOT; 2147483647" maxBytesPerRead = QUOT; 2147483647" maxNameTableCharCount = QUOT; 2147483647" />

  &NBSP; &NBSP; &NBSP; < / binding>

  &NBSP; &NBSP; < / basicHttpBinding>

  &NBSP; &NBSP; < webHttpBinding>

  &NBSP; &NBSP; &NBSP; < binding name =" myWebBinding"  maxBufferPoolSize = QUOT; 2147483647" maxReceivedMessageSize = QUOT; 2147483647" MAXBUFFERSIZE = QUOT; 2147483647" transferMode = QUOT;串流" />

  &NBSP; &NBSP; < / webHttpBinding>

  &NBSP; < / bindings>

  &NBSP; < behavior>

  &NBSP; &NBSP; < serviceBehaviors>

  &NBSP; &NBSP; &NBSP; < behavior name =" ServiceBehavior">

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceMetadata httpGetEnabled =" false" />

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceDebug includeExceptionDetailInFaults =" false" />

  &NBSP; &NBSP; &NBSP; < / behavior>

  &NBSP; &NBSP; &NBSP; < behavior name =" SimpleService">

  &NBSP; &NBSP; &NBSP; &NBSP; <! - 为避免泄露元数据信息,请在部署前将以下值设置为false - >

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceMetadata httpGetEnabled =" true" policyVersion =" Policy15" />

  &NBSP; &NBSP; &NBSP; &NBSP; <! - 要接收故障中的异常详细信息以进行调试,请将以下值设置为true。 在部署之前设置为false以避免泄露异常信息 - >

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceDebug includeExceptionDetailInFaults =" false" />

  &NBSP; &NBSP; &NBSP; < / behavior>

  &NBSP; &NBSP; < / serviceBehaviors>

  &NBSP; &NBSP; < endpointBehaviors>

  &NBSP; &NBSP; &NBSP; < behavior name =" jsonBehavior">

  &NBSP; &NBSP; &NBSP; &NBSP; < webHttp />

  &NBSP; &NBSP; &NBSP; < / behavior>

  &NBSP; &NBSP; < / endpointBehaviors>

  &NBSP; < / behavior>

  < /system.serviceModel>

  < configuration>

<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <system.serviceModel>
    <services>
      <service name="MyWCFWinSrv.SoapCommunication" behaviorConfiguration="ServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost/SoapCommunication"/>
          </baseAddresses>
        </host>
        <endpoint address ="SoapCommunication" binding="netNamedPipeBinding" contract="MyWCFWinSrv.ISoapCommunication"/>
        <endpoint address ="SoapCommunication/mex" binding="mexNamedPipeBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingClient" transferMode="Streamed" messageEncoding="Mtom" maxReceivedMessageSize="10067108864" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="myWebBinding"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" />
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
        <behavior name="SimpleService">
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="jsonBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <configuration>

希望在这里找到帮助。

提前谢谢




推荐答案

Hello MeTehila,请尝试明确指定mex端点地址。此外,我可能是错的,但我相信您希望将元数据作为http请求传递,即使该服务使用不同的协议。端点的目的是描述
服务而不是被调用,因此它不必是相同的prototocl,只需要相同的服务:

Hello MeTehila, try specifying the mex endpoint address explicitly. Also, I could be wrong but I believe you want to deliver the metadata as a http request even though the service uses a different protocol. The purpose of the endpoint is to describe the service and not t be called so it does not have to be the same prototocl, just the same service:

https:// social.msdn.microsoft.com/Forums/vstudio/en-US/0ca5c79a-ed72-4458-b476-2f4d8477c64f/how-to-get-wsdl-for-a-nettcpbinding-wcf?forum=wcf

https://social.msdn.microsoft.com/Forums/vstudio/en-US/0ca5c79a-ed72-4458-b476-2f4d8477c64f/how-to-get-wsdl-for-a-nettcpbinding-wcf?forum=wcf


这篇关于使用netNamedPipeBinding在Windows服务中使用wcf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆