错误"未找到端点"在调用操作时在WCF服务中

时间:2016-12-20 03:02:45

标签: c# wcf wcf-endpoint

我在WCF中开发了一个REST Web服务。当我浏览http://localhost:18349/SvcLipigas.svc时,我看到了该服务的主页。当我加载http://localhost:18349/SvcLipigas.svc?wsdl时,我可以看到定义,依此类推。

然而,当我尝试运行一个操作时,我得到了#34; Endpoint not found"错误。

这是SVC文件:

<div class="error">
<?php
if(!empty($errors)){
  echo "<p class='err'>".nl2br($errors)."</p>";
?>
</div>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
  <div class="touch">
    <div class="name">
      <input type="text" name="name" placeholder="Name" value='<?php echo htmlentities($nombre) ?>'>
    </div>
    <div class="email">
      <input type="text" name="mail"  placeholder="Email" value='<?php echo htmlentities($email) ?>'>
    </div>
    <div class="phone">
      <input type="tel" name="phone" placeholder="Phone" value='<?php echo htmlentities($telefono) ?>'>
    </div>
    <div class="select-pro">
      <select name="producto">
        <option value="0" selected>Affair...</option>
        <option value="1">Product 1</option>
        <option value="2">Product 2<option>
        <option value="3">Product 3</option>
        <option value="4">Other</option>
      </select>
    </div>
    <div class="Customer-message">
      <textarea id="message" name="message" placeholder="Su consulta..."><?php echo htmlentities($mensaje) ?></textarea>
    </div>
    <div class="capcha">
      <img src="image.php" name="vcode" id="phoca-captcha"/>
      <input name="vcode" type="text" placeholder="Codigo captcha">
    </div>
      <input type="submit" name="submit" value="Enviar">
  </div>
</form>
<?php
}
else
{
?>

<p>thanks for contacting us.</p>

<?php
}
?>

这是方法定义:

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

最后,这是web.config:

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

编辑:

这是WSDL:

<?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>

1 个答案:

答案 0 :(得分:0)

您已启用httpsGet。但是您没有指定URL。 请执行以下操作以纠正问题

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

如果您没有使用SSL,请删除httpsGetenabled

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