Rest resources not found, receiving 404 error however wsdl is visible RRS feed

  • Question

  • I am trying to make a rest service and test it. Following is the resulted wsdl file, but I am not able to get the GetData method work.

    My WSDL file from `http://localhost:21611/Service1.svc?wsdl`

        <wsdl:definitions name="Service1" targetNamespace="">
            <xsd:schema targetNamespace="">
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd0" namespace=""/>
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd1" namespace=""/>
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd2" namespace=""/>
          <wsdl:message name="IService1_GetData_InputMessage">
            <wsdl:part name="parameters" element="tns:GetData"/>
          <wsdl:message name="IService1_GetData_OutputMessage">
            <wsdl:part name="parameters" element="tns:GetDataResponse"/>
          <wsdl:message name="IService1_GetDataUsingDataContract_InputMessage">
            <wsdl:part name="parameters" element="tns:GetDataUsingDataContract"/>
          <wsdl:message name="IService1_GetDataUsingDataContract_OutputMessage">
            <wsdl:part name="parameters" element="tns:GetDataUsingDataContractResponse"/>
          <wsdl:portType name="IService1">
            <wsdl:operation name="GetData">
              <wsdl:input wsaw:Action="" message="tns:IService1_GetData_InputMessage"/>
              <wsdl:output wsaw:Action="" message="tns:IService1_GetData_OutputMessage"/>
            <wsdl:operation name="GetDataUsingDataContract">
              <wsdl:input wsaw:Action="" message="tns:IService1_GetDataUsingDataContract_InputMessage"/>
              <wsdl:output wsaw:Action="" message="tns:IService1_GetDataUsingDataContract_OutputMessage"/>
          <wsdl:service name="Service1"/>


        <?xml version="1.0"?>
            <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
            <bindings />
              <service behaviorConfiguration="MyServiceBehavior" name="test.Service1">
                <endpoint address="Service1.svc" behaviorConfiguration="myRestBehavior" binding="webHttpBinding"
                  name="epname" contract="test.IService1" />
                <behavior name="myRestBehavior">
                  <webHttp defaultBodyStyle="Wrapped" />
                <behavior name="MyServiceBehavior">
                  <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding" httpGetBindingConfiguration="" />
                  <serviceDebug includeExceptionDetailInFaults="false" />
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
            <modules runAllManagedModulesForAllRequests="true"/>
                To browse web app root directory during debugging, set the value below to true.
                Set to false before deployment to avoid disclosing web app folder information.
            <directoryBrowse enabled="true"/>

    WCF service files:

        Public Interface IService1
            Function GetData() As String
        End Interface
        Public Class Service1
            Implements IService1
            Public Function GetData() As String Implements IService1.GetData
                Return "Welcome"
            End Function
        End Class

    I tried with urls like but could not get any result, could you please educate me on this.


    Also, I receive 404 error when i try: `http://localhost:21611/Service1.svc/GetData` and when I use UriTemplate:="GetData", the result is still the same.

    • Edited by surpavan Wednesday, July 30, 2014 6:39 AM
    Wednesday, July 30, 2014 6:38 AM


  • Hi,

    First please try to note that:
    The WCF REST Service has no concept of a WSDL in WCF, the WSDL is used only for the WCF SOAP Service.  In your case the URL for "?wsdl" works, it is because that you have used the following <serviceMetadata httpGetEnabled="true"...> or have defined the mex endpoint, which is what serves up the WSDL. This is usually added by default if you add a WCF service through the VisualStudio wizards. If it is there, it can be removed if you don't plan on using the WCF SOAP Service.

    Then for your question, you have used the following:
     <endpoint address="Service1.svc" .......>

    So your address will be the following with the UriTemplate:="GetData":
    http://localhost:21611/Service1.svc/Service1.svc/GetData .

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 31, 2014 5:22 AM