2010-10-28 135 views
1

我想從我的WCF服務中使用ASMX Web服務。這是我做了什麼,我得到以下錯誤。 「 」在「http:// ...」沒有端點監聽可以接受該消息,這通常是由不正確的地址或SOAP操作引起的。幫幫我吧。我哪裏做錯了嗎?我缺少什麼?從WCF消費ASMX WebService

我創建了一個WCF服務庫,並添加到ASMX Web服務的引用與提供給我的WSDL文件的幫助。

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> 

+0

是否將引用添加爲WebService?或作爲大會? – pjnovas 2010-10-28 17:55:49

+0

我將該參考添加爲Webservice。 – BumbleBee 2010-10-28 18:05:24

回答

1

嘿,在這個崗位有這個問題的一個很酷的解釋:Stackoverflow post

如果你沒有得到的麻煩。 ..只需在解決方案上按F5並站立網站...然後轉到您的控制檯應用程序構建文件(在調試文件夾內)並執行.exe。 似乎你正試圖在同一個調試器上使用你的web服務主機和客戶端。

希望它有幫助!

+0

嗨Darkxes,謝謝。我按照你的說法嘗試過。但是我輸入輸入後立即關閉了我的commad提示符。 – BumbleBee 2010-10-28 19:31:20

+0

這是我在我的控制檯WCFServiceReference.Service1Client client = new CLUE.WCFServiceReference.Service1Client(); Console.WriteLine(「輸入名稱:」); string name = Console.ReadLine(); Console.WriteLine(client.GetData(name)); Console.Read(); – BumbleBee 2010-10-28 19:34:40

+0

Darkxes,請你幫我解決這個問題。我需要儘快完成它。謝謝 – BumbleBee 2010-10-28 20:09:30