2013-07-26 4 views
6

पहचाना नहीं गया है यह वास्तव में मुझे कुछ घंटों तक चिपका रहा है। मैंने एक टीसीपी बाध्यकारी का उपयोग कर सबसे सरल डब्ल्यूसीएफ सेवा बनाई।नेट टीसीपी बाध्यकारी: यूआरआई उपसर्ग को

<system.serviceModel> 
    <services> 
     <service name="WcfTcpService.TestTcpService" behaviorConfiguration="TestServiceBehavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:808/WcfTcpService.TestTcpService" /> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding" contract="WcfTcpService.ITestTcpService"></endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"></endpoint> 
     </service> 
    </services> 
    <bindings> 
     <netTcpBinding> 
     <binding name="tcpBinding" portSharingEnabled="true"> 
      <security mode="None"></security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="TestServiceBehavior"> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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> 
    <!--<protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
     <add binding="netTcpBinding" scheme="net.tcp" /> 
    </protocolMapping>-->  
    <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />--> 
    </system.serviceModel> 

यह सेवा IIS में होस्ट किया गया है:

namespace WcfTcpService 
{ 
    public class TestTcpService : ITestTcpService 
    { 
     public string Hello(string name) 
     { 
      return "Hello, " + name + "!"; 
     } 
    } 
} 

namespace WcfTcpService 
{ 
    [ServiceContract] 
    public interface ITestTcpService 
    { 
     [OperationContract] 
     string Hello(string name); 
    } 
} 

Web.config फ़ाइल निम्न अनुभाग है

detailed settings

अब, जब से net.tcp://localhost:808/WcfTcpService.TestTcpService के लिए एक संदर्भ जोड़ने की कोशिश कर एक क्लाइंट एप्लिकेशन, मैं त्रुटि प्राप्त करता रहता हूं:

The URI prefix is not recognized. 
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/WcfTcpService.TestTcpService'. 
The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost/WcfTcpService.TestTcpService' is unavailable for the protocol of the address. 
If the service is defined in the current solution, try building the solution and adding the service reference again. 

net.tcp सेवा चल रही है, मुझे WcfTestClient.exe के साथ एक ही त्रुटि मिलती है। और मैं सफलतापूर्वक http://localhost/WcfTcpService/TestTcpService.svc चला सकता हूं।

मैंने Google की खोज की है लेकिन कुछ भी नहीं आया है।

धन्यवाद!

संपादित करें:

'डिफ़ॉल्ट वेब साइट' की बाइंडिंग स्क्रीन इस तरह btw दिखता है:

bindings

+1

आप जब आप चुनते हैं "सेवा संदर्भ जोड़ें" इस त्रुटि मिलता है? इस संवाद में पता http: //localhost/WcfTcpService/TestTcpService.svc का प्रयास करें। IIS में बाइंडिंग की जाँच करें – empi

+0

/आईआईएस व्यक्त इस सवाल देखें: http://stackoverflow.com/questions/3188618/enabling-net-tcp – nakchak

+0

@empi तुम मुझे मजाक कर रहे हैं करने के लिए मिल गया है ... कि काम करता है। यदि आप इसे समाधान के रूप में पोस्ट करते हैं, तो मैं इसे स्वीकार करूंगा। धन्यवाद! – Nullius

उत्तर

8

जब आप सेवा netTcpBinding का उपयोग करता है बना सकते हैं और आप सेवा संदर्भ जोड़ें करना चाहते हैं विजुअल स्टूडियो में आपको http पता (httpGetEnabled) का उपयोग करना चाहिए जो वास्तविक टीसीपी पता नहीं है जो सेवा सुनता है। तो समाधान स्थानीय सेवा/WCFTcpService/TestTcpService.svc को सेवा संदर्भ संवाद में एक यूआरएल के रूप में सेट करना था।

+1

बस पूरा होने के लिए: यह वास्तव में 'net.tcp: // localhost/WcfTcpService/TestTcpService.svc' है जो चाल है। – Nullius

0

मैं एक ही समस्या थी और मैं नीचे के रूप में web.config बदल दिया है:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true"> 
 
     <baseAddressPrefixFilters> 
 
     <add prefix="net.tcp://YourBaseUrl"/> 
 
     </baseAddressPrefixFilters> 
 
    </serviceHostingEnvironment>

संबंधित मुद्दे