Error "Endpoint not found" in WCF Service when calling an operation

2.3k views Asked by At

I have developed a REST Web Service in WCF. When I browse http://localhost:18349/SvcLipigas.svc I see the home page of the service. When I load http://localhost:18349/SvcLipigas.svc?wsdl I can see the definition, and so on.

However, when I try to run an operation, I get the "Endpoint not found" error.

This is the SVC file:

<%@ ServiceHost Language="C#" Debug="true" Service="WS_PedidoCliente.SvcLipigas" CodeBehind="SvcLipigas.svc.cs" %>

This is the method definition:

[OperationContract]
[WebInvoke(Method = "GET",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.WrappedRequest,
    UriTemplate = "AlmacenaPedido/{telefono}/{fechaPedido}/{horaPedido}/{codigoInterno}/{descripcionProducto}/{cantidadProducto}/{valorUnitario}/{kilosProducto}/{fechaEntrega}/{horaEntrega}/{fechaDespacho}/{horaDespacho}")]
int AlmacenaPedido(string telefono, string fechaPedido, string horaPedido, string codigoInterno, string descripcionProducto,
                   string cantidadProducto, string valorUnitario, string kilosProducto, string fechaEntrega, string horaEntrega,
                   string fechaDespacho, string horaDespacho);

And finally, this is the web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
  <services>
    <service name="WS_PedidoCliente.SvcLipigas" behaviorConfiguration="serviceBehavior">
      <endpoint address=""
                binding="webHttpBinding"
                contract="WS_PedidoCliente.ISvcLipigas"
                bindingNamespace="http://ws.lipigas.cl"
                behaviorConfiguration="web"></endpoint>
          </service>
   </services>    
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <!-- 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>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>    
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 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>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <connectionStrings>
    <add name="LipigasEntities" connectionString="metadata=res://*/Model.Lipigas.csdl|res://*/Model.Lipigas.ssdl|res://*/Model.Lipigas.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=SLLCOSTO;PASSWORD=uni_1915sll;USER ID=PEDIDO&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

EDIT:

This is the WSDL:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://ws.lipigas.cl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SvcLipigas" targetNamespace="http://ws.lipigas.cl">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://ws.lipigas.cl">
<xs:element name="AlmacenaPedido">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="telefono" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="fechaPedido" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="horaPedido" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="codigoInterno" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="descripcionProducto" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="cantidadProducto" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="valorUnitario" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="kilosProducto" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="fechaEntrega" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="horaEntrega" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="fechaDespacho" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="horaDespacho" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AlmacenaPedidoResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="AlmacenaPedidoResult" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
<xs:element name="byte" nillable="true" type="xs:byte"/>
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
<xs:element name="double" nillable="true" type="xs:double"/>
<xs:element name="float" nillable="true" type="xs:float"/>
<xs:element name="int" nillable="true" type="xs:int"/>
<xs:element name="long" nillable="true" type="xs:long"/>
<xs:element name="QName" nillable="true" type="xs:QName"/>
<xs:element name="short" nillable="true" type="xs:short"/>
<xs:element name="string" nillable="true" type="xs:string"/>
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
<xs:element name="char" nillable="true" type="tns:char"/>
<xs:simpleType name="char">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration"/>
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid"/>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName"/>
<xs:attribute name="Id" type="xs:ID"/>
<xs:attribute name="Ref" type="xs:IDREF"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="ISvcLipigas_AlmacenaPedido_InputMessage">
<wsdl:part name="parameters" element="tns:AlmacenaPedido"/>
</wsdl:message>
<wsdl:message name="ISvcLipigas_AlmacenaPedido_OutputMessage">
<wsdl:part name="parameters" element="tns:AlmacenaPedidoResponse"/>
</wsdl:message>
<wsdl:portType name="ISvcLipigas">
<wsdl:operation name="AlmacenaPedido">
<wsdl:input wsaw:Action="http://ws.lipigas.cl/ISvcLipigas/AlmacenaPedido" message="tns:ISvcLipigas_AlmacenaPedido_InputMessage"/>
<wsdl:output wsaw:Action="http://ws.lipigas.cl/ISvcLipigas/AlmacenaPedidoResponse" message="tns:ISvcLipigas_AlmacenaPedido_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:service name="SvcLipigas"/>
</wsdl:definitions>
1

There are 1 answers

1
Kalyan On

You have enabled httpsGet. But you have not specified URL. Do the following to rectify the issue

<behaviors>
 <serviceBehaviors>
  <behavior name="serviceBehavior">
    <serviceMetadata httpsGetEnabled="true" 
     httpsGetUrl="https://myComputerName/myEndpoint" />

If you are not using SSL then remove httpsGetenabled

follow the below link for better understanding http://www.allenconway.net/2012/05/creating-wcf-restful-service-and-secure.html