从WCF使用ASMX Web服务

时间:2010-10-28 17:37:05

标签: wcf web-services

我正在尝试从我的WCF服务中使用ASMX Web服务。这是我做的,我得到以下错误。 “没有端点侦听”http:// ...“可以接受消息。这通常是由不正确的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

请帮帮我。我在哪里做错了?我缺少什么?

我创建了一个WCF服务库,并在提供给我的WSDL文件的帮助下添加了对ASMX Web服务的引用。

  namespace WCFClueClient
{
        public class Service1 : IService1
    {
        public string GetData(string value)
        {
         ClueClientServiceReference.InteractiveOrderHandlerClient client = new WCFClueClient.ClueClientServiceReference.InteractiveOrderHandlerClient();
            string response = client.handleInteractiveOrder(value);
            return string.Format("You entered: {0}", response);
        }

           }   

我有一个控制台应用程序,它引用了我的WCF服务

  namespace CLUE
{
    class Program
    {
        static void Main(string[] args)
        {

            CLUETestServiceReference.Service1Client client = new CLUE.CLUETestServiceReference.Service1Client();

           string response =  client.GetData("JOHN DOE");

                }
    }
}
  

我的app.config文件

 <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="InteractiveOrderHandlerBinding" 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>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IService1" 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="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://alalppnc079.choicepoint.net:8280/CPRules-rfCommunicationEJB/InteractiveOrderHandlerURI"
    binding="basicHttpBinding" bindingConfiguration="InteractiveOrderHandlerBinding"
    contract="ClueClientServiceReference.InteractiveOrderHandler"
    name="InteractiveOrderHandlerPort" />
  <endpoint address="http://localhost:8731/Design_Time_Addresses/WCFClueClient/Service1/"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
    contract="WCFCLUETEstServiceReference.IService1" name="WSHttpBinding_IService1">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>
<services>
  <service name="WCFClueClient.Service1" behaviorConfiguration="WCFClueClient.Service1Behavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCFClueClient/Service1/"   />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address=""  binding="wsHttpBinding" contract="WCFClueClient.IService1">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFClueClient.Service1Behavior">
      <!-- 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>

1 个答案:

答案 0 :(得分:1)

嘿,在这篇文章中,对这个问题有一个很酷的解释:Stackoverflow post

如果你没有遇到麻烦...只需在你的解决方案上按F5并站在网站上......然后转到你的控制台应用程序构建文件(在调试文件夹内)并执行.exe。 您似乎正在尝试使用同一调试器中的Web服务主机和客户端。

希望它有所帮助!

相关问题