服务工作从wcfTestClient,但未能在控制台应用程序 [英] Service works from wcfTestClient but fails in Console Application

查看:158
本文介绍了服务工作从wcfTestClient,但未能在控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务。该服务工作正常,当我测试使用wcfTestClient。当我从控制台应用程序客户端调用它抛出以下错误:

I have a service. The service is working fine when I tested using wcfTestClient. When I am calling from console app client it is throwing following error:

找不到了ServiceModel客户端配置节中引用合同'ICalculationService默认终结点元素。这可能是因为没有配置文件找到您的应用程序,或者是因为没有终点的元素匹配这份合同可以在客户端元素中找到。

Could not find default endpoint element that references contract 'ICalculationService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

服务跟踪:

描述:无法查找一个信道接收进来的消息。无论是端点或SOAP动作没有被发现。   资料来源:System.ServiceModel.Activati​​on.HostedHttpTransportManager / 28072850

Description: Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found. Source:System.ServiceModel.Activation.HostedHttpTransportManager/28072850

什么都可能是可能出现的问题?

What all could be the possible issues?

参考:<一href="http://stackoverflow.com/questions/8725353/there-was-no-channel-that-could-accept-the-message-with-action">There没有渠道,可以接受的行动消息

服务配置

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceTypeBehaviors" >
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_CalculationServiceInterface"
        closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
        sendTimeout="00:01: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="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors">
    <endpoint address="CalculationService" behaviorConfiguration=""
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
        contract="ICalculationService" />
  </service>
  </services>
  </system.serviceModel>

客户端配置

   <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_CalculationServiceInterface"
                closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
                sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
                hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="524288" maxStringContentLength="524288" maxArrayLength="524288"
                    maxBytesPerRead="524288" maxNameTableCharCount="524288" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:2724/CalculationService.svc/CalculationService" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
            contract="ICalculationService" name="CalculationServicePort" />
    </client>
    </system.serviceModel>

WSDL

  <definitions xmlns:import0="urn:lijo:demos:multiplyservice:messages:v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:import1="urn:lijo:demos:multiplyservice:data:v1" xmlns:tns="urn:lijo:demos:multiplyservice:calculation:v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CalculationService" targetNamespace="urn:lijo:demos:multiplyservice:calculation:v1" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />

  <types>
  <xsd:schema>
  <xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantMessages.xsd" namespace="urn:lijo:demos:multiplyservice:messages:v1" />
  <xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantData.xsd" namespace="urn:lijo:demos:multiplyservice:data:v1" />
  </xsd:schema>
  </types>

  <message name="getMultiplied">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
  <part name="parameters" element="import0:getMultiplied" />
  </message>

  <message name="getMultipliedResponse">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
  <part name="parameters" element="import0:getMultipliedResponse" />
  </message>

  <portType name="CalculationServiceInterface">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />

  <operation name="getMultiplied">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
  <input message="tns:getMultiplied" />
  <output message="tns:getMultipliedResponse" />
  </operation>

  </portType>

  <binding name="BasicHttpBinding_CalculationServiceInterface" type="tns:CalculationServiceInterface">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
  <operation name="getMultiplied">
  <soap:operation soapAction="urn:lijo:demos:multiplyservice:calculation:v1:getMultiplied" style="document" />
  <input>
    <soap:body use="literal" />
  </input>
  <output>
    <soap:body use="literal" />
  </output>
  </operation>
  </binding>
  <service name="CalculationServicePort">
  <port name="CalculationServicePort" binding="tns:BasicHttpBinding_CalculationServiceInterface">
  <soap:address location="http://localhost/CalculationService" />
  </port>
  </service>
  </definitions>

XSD文件:

XSD File:

所要求的XSD可以在<一个被发现href="http://stackoverflow.com/questions/12420314/one-wcf-service-two-clients-one-client-does-not-work">One WCF服务 - 两个客户端;一个客户端不能正常工作

The required XSD can be found in One WCF service – two clients; One client does not work

推荐答案

让我不得不承认,这是从我身边一个大错。我是保持在output.config文件中的客户端配置(由WCSF蓝工具生成)。当我把它复制到的app.config它工作得很好。

Let me admit that it was a blunder from my side. I was keeping the client configurations in output.config file (generated by the WCSF Blue tool). When I copied it to the app.config it worked fine.

这篇关于服务工作从wcfTestClient,但未能在控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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