2016-12-20 26 views
0

我在WCF中开发了一个REST Web服务。当我浏览http://localhost:18349/SvcLipigas.svc时,我看到了服务的主页。当我加载http://localhost:18349/SvcLipigas.svc?wsdl时,我可以看到定义,等等。调用操作时WCF服务中的“端点未找到”错误

但是,当我尝试运行某个操作时,出现“找不到端点”错误。

这是SVC文件:

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

这是该方法的定义:

[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); 

最后,这是在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> 

编辑:

这是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> 
+0

你可以看到你的WSDL操作的合同来纠正问题

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

? – Kalyan

+0

请分享提出服务请求的客户端代码 – Kalyan

+0

@KalyanaSundaram我在问题中添加了整个WSDL。在那里你可以看到操作合同。 – jstuardo

回答

0

您已启用httpsGet。但是你没有指定URL。 请执行下列操作。如果您不使用SSL然后取出httpsGetenabled

按照下面的链接,更好地理解 http://www.allenconway.net/2012/05/creating-wcf-restful-service-and-secure.html

+0

它没有帮助,事实上,在web.config中,在serviceMetadata设置之前,此注释出现:<! - 为避免公开元数据信息,请将下面的值设置为在部署之前为false - >。这表明我这个设置与端点定义错误无关。 – jstuardo

相关问题