无法在WCF中调用单向操作合约

发布于 2024-12-28 13:51:03 字数 3415 浏览 0 评论 0原文

我有一个单向 WCF 服务,其主要目的是将网页内容作为字符串获取,并进行一些操作。但是我似乎无法调用操作合同。它只是没有被调用。如果我发送短文本(“Hello World”)而不是网页内容,一切都会按预期进行。我在 web.config 中将 maxReceiveMessageSize 设置为 max 但仍然无法传递网页内容。这是客户端的 web.config

<system.serviceModel>
<bindings>
  <basicHttpBinding>

    <binding name="basicBinding" allowCookies="false" closeTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
             maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"
             textEncoding="utf-8" transferMode="Buffered">

      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="16384"/>

      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>

    </binding>

  </basicHttpBinding>
</bindings>

<client>
  <endpoint name="basicHttpEndPoint"
            address="http://localhost:7777/Serializer.svc"
            binding="basicHttpBinding"
            contract="Shared.ISerializer" 
            bindingConfiguration="basicBinding" />

</client>

这是我的服务的 web.config

  <system.serviceModel>
<services>
  <service name="SerializerService">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="basicBinding"
              contract="Shared.ISerializer" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="basicBinding" allowCookies="false" closeTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
             maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"
             textEncoding="utf-8" transferMode="Buffered">

      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" 
                    maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>

      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>

    </binding> 
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- 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>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我错过了什么吗?提前致谢。

I have a one-way WCF service, which main purpose is to get Web Page content as a string, and make some manipulations. However I can't seem to be able to call Operation Contract. It just doesn't get called. If instead of WebPage Content, I'm sending short text ( "Hello World" ) everything works as expected. I set maxReceiveMessageSize to max in web.config but I still can't pass WebPage content. Here is client web.config

<system.serviceModel>
<bindings>
  <basicHttpBinding>

    <binding name="basicBinding" allowCookies="false" closeTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
             maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"
             textEncoding="utf-8" transferMode="Buffered">

      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="16384"/>

      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>

    </binding>

  </basicHttpBinding>
</bindings>

<client>
  <endpoint name="basicHttpEndPoint"
            address="http://localhost:7777/Serializer.svc"
            binding="basicHttpBinding"
            contract="Shared.ISerializer" 
            bindingConfiguration="basicBinding" />

</client>

And here is my service's web.config

  <system.serviceModel>
<services>
  <service name="SerializerService">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="basicBinding"
              contract="Shared.ISerializer" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="basicBinding" allowCookies="false" closeTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
             maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"
             textEncoding="utf-8" transferMode="Buffered">

      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" 
                    maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>

      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>

    </binding> 
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- 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>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Am I missing something ? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深已缘浅 2025-01-04 13:51:03

查看您的配置,我猜测服务实现类型不称为 SerializerService,但实际上也在命名空间中,这意味着 WCF 根本不使用您的服务配置,而只是使用默认端点 使用

命名空间完全限定服务名称你的价值观应该得到重视

Looking at your config I would guess that the service implmentation type is not called SerializerService but is actually also in a namespace which means WCF isn;t using your service configuration at all and is just using a default endpoint

Fully qualify the service name with the namespace and your values should get picked up

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文