none
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="http://tempuri.org/">
          <wsdl:types>
            <xsd:schema targetNamespace="http://tempuri.org/Imports">
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
              <xsd:import schemaLocation="http://localhost:21611/Service1.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/test"/>
            </xsd:schema>
          </wsdl:types>
          <wsdl:message name="IService1_GetData_InputMessage">
            <wsdl:part name="parameters" element="tns:GetData"/>
          </wsdl:message>
          <wsdl:message name="IService1_GetData_OutputMessage">
            <wsdl:part name="parameters" element="tns:GetDataResponse"/>
          </wsdl:message>
          <wsdl:message name="IService1_GetDataUsingDataContract_InputMessage">
            <wsdl:part name="parameters" element="tns:GetDataUsingDataContract"/>
          </wsdl:message>
          <wsdl:message name="IService1_GetDataUsingDataContract_OutputMessage">
            <wsdl:part name="parameters" element="tns:GetDataUsingDataContractResponse"/>
          </wsdl:message>
          <wsdl:portType name="IService1">
            <wsdl:operation name="GetData">
              <wsdl:input wsaw:Action="http://tempuri.org/IService1/GetData" message="tns:IService1_GetData_InputMessage"/>
              <wsdl:output wsaw:Action="http://tempuri.org/IService1/GetDataResponse" message="tns:IService1_GetData_OutputMessage"/>
            </wsdl:operation>
            <wsdl:operation name="GetDataUsingDataContract">
              <wsdl:input wsaw:Action="http://tempuri.org/IService1/GetDataUsingDataContract" message="tns:IService1_GetDataUsingDataContract_InputMessage"/>
              <wsdl:output wsaw:Action="http://tempuri.org/IService1/GetDataUsingDataContractResponse" message="tns:IService1_GetDataUsingDataContract_OutputMessage"/>
            </wsdl:operation>
          </wsdl:portType>
          <wsdl:service name="Service1"/>
        </wsdl:definitions>

    WebConfig:

        <?xml version="1.0"?>
        <configuration>
        
          <system.web>
            <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
          </system.web>
          <system.serviceModel>
            <bindings />
            <services>
              <service behaviorConfiguration="MyServiceBehavior" name="test.Service1">
                <endpoint address="Service1.svc" behaviorConfiguration="myRestBehavior" binding="webHttpBinding"
                  name="epname" contract="test.IService1" />
              </service>
            </services>
            <behaviors>
              <endpointBehaviors>
                <behavior name="myRestBehavior">
                  <webHttp defaultBodyStyle="Wrapped" />
                </behavior>
              </endpointBehaviors>
              <serviceBehaviors>
                <behavior name="MyServiceBehavior">
                  <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding" httpGetBindingConfiguration="" />
                  <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
              </serviceBehaviors>
            </behaviors>
            
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
          </system.serviceModel>
          <system.webServer>
            <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"/>
          </system.webServer>
        
        </configuration>

    WCF service files:

        <ServiceContract()>
        Public Interface IService1
        
            <OperationContract()>
            <WebGet>
            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.

        http://localhost:21611/Service1.svc?wsdl
        http://localhost:21611/Service1.svc?wsdl/GetData
        http://localhost:21611/Service1.svc?wsdl/GetData/
        http://localhost:21611/Service1.svc/GetData
        http://localhost:21611/Service1.svc/GetData/

    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

Answers

  • 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
    Moderator