2013-03-28 5 views
12

उम डब्ल्यूसीएफ के लिए काफी नया है। मुझे लगता है कि मैंने थोड़ा गड़बड़ कर लिया है। तो यह मैं अब तक क्या किया है और मैं आईआईएस मेंडब्ल्यूसीएफ त्रुटि: सापेक्ष अंत बिंदु पते

पहले संविदा

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text; 
using YangkeeServer.dto; 

namespace YangkeeServer 
    { 

public class Service1 : IService1 
{ 
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "single")] 
    public YangkeeTrailerDTO getTrailor() 
    { 
     return new YangkeeTrailerDTO() 
     { 
      loanFrom = "heaven" 
     }; 
    } 


    [WebInvoke(Method = "GET", 
     ResponseFormat = WebMessageFormat.Json, 
     UriTemplate = "datum/{id}")] 
    public Test getName(string id) 
    { 
     return new Test() 
     { 
      Id = Convert.ToInt32(id) * 12, 
      Name = "Leo Messi" 
     }; 
    } 
} 
} 

मेरी WCF सेवा की मेजबानी की है और यह मेरा web.config फ़ाइल

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 

    </system.web> 
    <system.serviceModel> 

    <services> 

     <service name="YangkeeServer.Service1"> 

     <endpoint 
      contract="YangkeeServer.IService1" 
     binding="webHttpBinding" 
     behaviorConfiguration="WebHttp" 
     address="http://localhost:7000/Service1.svc"> 
     </endpoint> 

    </service> 

     <service name="YangkeeServer.Service2"> 

     <endpoint 
      contract="YangkeeServer.IService2" 
     binding="webHttpBinding" 
     behaviorConfiguration="WebHttp" 
     address="http://localhost:7000/Service2.svc"> 
     </endpoint> 

    </service> 

     <service name="YangkeeServer.YangkeeTrailer"> 

     <endpoint 
      contract="YangkeeServer.IYangkeeTrailor" 
      binding="webHttpBinding" 
      behaviorConfiguration="WebHttp" 
     address="http://localhost:7000/YangkeeTrailor.svc"> 
     </endpoint> 

     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="WebHttp"> 
     <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

</configuration> 

है और उम इस का उपयोग करते हुए urlhttp: // स्थानीय होस्ट: 7000/Service1.svc और उम इस त्रुटि

Server Error in '/' Application. 

When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true  in configuration, the endpoints are required to specify a relative address. If you are specifying a  relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://localhost:7000/Service1.svc'. 

किसी भी एक मुझे बता सकते हैं जहां हो रही क्या मैंने गलत किया? पहले ही, आपका बहुत धन्यवाद। enter image description here

उत्तर

28

सेट सेवा समाप्ति बिंदु का पता बस सेवा फ़ाइल नाम (इस रिश्तेदार हिस्सा है):

address="Service1.svc" 

या खाली करने के लिए पता सेट प्रत्येक endpoint के लिए (मुझे नहीं लगता कि इसकी जरूरत है जब में की मेजबानी विकास के वातावरण या IIS में)

address="" 

देखें this answer to another question

प्रासंगिक हिस्सा है:

वर्चुअल निर्देशिका (आईआईएस में) जहां आपकी * .svc फ़ाइल मौजूद है, आपकी सेवा एंडपॉइंट के पते को परिभाषित करती है।

+1

धन्यवाद टिप पता = स्थापित करने के लिए के लिए "", एक ही रास्ता मैं इसे बाद काम करने के लिए मिल सकता है एकाधिक आईआईएस होस्ट नाम बाइंडिंग जोड़ना। चीयर्स। –

+0

धन्यवाद, यह मेरे लिए भी काम करता है :) –

9

इस त्रुटि listenUri = "/" ... करने के लिए सेवा समाप्ति बिंदु को ठीक करने के लिए, मैं जोड़ा ...।

उदाहरण:

<service name="_name_"> 
    <endpoint address="http://localhost:_port_/.../_servicename_.svc" 
    name="_servicename_Endpoint" 
    binding="basicHttpBinding" 
    bindingConfiguration="GenericServiceBinding" 
    contract="_contractpath_._contractname_" 
    listenUri="/" /> 
</service> 

MSDN: Multiple Endpoints at a Single ListenUri

+1

बहुत बहुत धन्यवाद ... यह काम करता है .. –

0

यह मेरे लिए काम करता है:

1. सम्मिलित इस सेवा के अंदर लाइनों:

<host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:7000/Service1.svc" /> 
     </baseAddresses> 
    </host> 

2. मान सेट करें का के रूप में bellow का पता:

पता = ""

पूर्ण कोड:

<service name="YangkeeServer.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:7000/Service1.svc" /> 
      </baseAddresses> 
     </host> 
     <endpoint 
      contract="YangkeeServer.IService1" 
      binding="webHttpBinding" 
      behaviorConfiguration="WebHttp" 
      address=""> 
     </endpoint> 
     </service> 
संबंधित मुद्दे