Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

I would like to create service reference to a WCF Rest Service

$
0
0

 Hi

I have a rest service but I would like to create a service reference of a web service. I have a project which created a reference to a WCF Rest Service but I don't know how

it created the reference... In this case, the host has a svc: Interfacesweb.svc which has an interface with soap:InterfacesWeb and a interface with rest:

IInterfacesWebRest

This is the web config of the service:

<?xml version="1.0"?><configuration>  <configSections>    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />    <section name="secureSettings" type="System.Configuration.NameValueSectionHandler" />  </configSections>  <log4net>    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">      <param name="File" type="log4net.Util.PatternString" value="D:\Logs\Aplicaciones\VNInterfacesWeb\\Log_%property{LogName}.txt"/>      <appendToFile value="true" />      <encoding value="utf-8" />      <layout type="log4net.Layout.PatternLayout">        <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>      </layout>    </appender>    <root>      <level value="ALL" />      <appender-ref ref="LogFileAppender" />    </root>  </log4net>    <system.web>    <compilation debug="true" targetFramework="4.0" />  </system.web>  <system.serviceModel>    <services>      <service name="Ws.InterfacesWeb.InterfacesWeb">        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="InterfacesWeb.Binding"                  name="InterfacesWeb" contract="Ws.InterfacesWeb.IInterfacesWeb">        </endpoint>      <endpoint name ="RESTEndPoint"                  contract ="Ws.InterfacesWeb.IInterfacesWebRest"                  binding ="webHttpBinding"                  address ="rest"                   bindingConfiguration="InterfacesWebRest.Binding"                  behaviorConfiguration ="restbehavior"/>      </service>    </services>    <bindings>      <webHttpBinding>        <binding name="InterfacesWebRest.Binding"                 maxBufferPoolSize="2147483647"                 maxReceivedMessageSize="4194304">          <readerQuotas maxDepth="2147483647"                         maxStringContentLength="2147483647"                        maxArrayLength="2147483647"                         maxBytesPerRead="2147483647"                         maxNameTableCharCount="2147483647" />          <security mode="None">            <transport clientCredentialType="None" />          </security>        </binding>      </webHttpBinding>            <wsHttpBinding>        <binding name="InterfacesWeb.Binding"                  maxBufferPoolSize="2147483647"          maxReceivedMessageSize="2147483647">          <readerQuotas maxDepth="2147483647"                         maxStringContentLength="2147483647"                        maxArrayLength="2147483647"                         maxBytesPerRead="2147483647"                         maxNameTableCharCount="2147483647" />          <security mode="None">            <transport clientCredentialType="None" />          </security>        </binding>        <binding name="main" closeTimeout="00:10:00" openTimeout="00:10:00"          receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"          transactionFlow="false" hostNameComparisonMode="StrongWildcard"          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"          allowCookies="false">          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />          <reliableSession ordered="true" inactivityTimeout="00:10:00"            enabled="false" />          <security mode="None">            <transport clientCredentialType="Windows" proxyCredentialType="None"              realm="" />            <message clientCredentialType="Windows" negotiateServiceCredential="true" />          </security>        </binding>        <binding name="main1">          <security mode="None" />        </binding>        <binding name="main2">          <security mode="None" />        </binding>        <binding name="main3">          <security mode="None" />        </binding>        <binding name="main4">          <security mode="None" />        </binding>        <binding name="main5">          <security mode="None" />        </binding>        <binding name="main6">          <security mode="None" />        </binding>        <binding name="main7">          <security mode="None" />        </binding>      </wsHttpBinding>    </bindings>    <client>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="ComerciosReference.IBackendService"        name="ComerciosWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="TerminalesReference.IBackendService"        name="TerminalesWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="OperacionesReference.IBackendService"        name="OperacionesWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="ConsultasReference.IBackendService"        name="ConsultasWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="InterfacesWebReference.IBackendService"        name="InterfacesWebWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint behaviorConfiguration="ManagementServiceBehaviour"        binding="wsHttpBinding" bindingConfiguration="main" contract="InterfaceReference.IBackendService"        name="InterfaceWSHttpBinding_IBackendService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint address="http://localhost:8732/Terminales" binding="wsHttpBinding"        bindingConfiguration="main1" contract="TerminalesReference.IBackendService"        name="main">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint address="http://localhost/Interfaces" binding="wsHttpBinding"        bindingConfiguration="main2" contract="InterfaceReference.IBackendService"        name="main1">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint address="http://localhost:8732/InterfacesWeb" binding="wsHttpBinding"        bindingConfiguration="main4" contract="InterfacesWebReference.IBackendService"        name="main3">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint address="http://localhost:8732/Comercios" binding="wsHttpBinding"        bindingConfiguration="main3" contract="ComerciosReference.IBackendService"        name="main2">        <identity>          <dns value="localhost" />        </identity>      </endpoint>      <endpoint address="http://localhost:8732/Operaciones" binding="wsHttpBinding"        bindingConfiguration="main5" contract="OperacionesReference.IBackendService"        name="main4">        <identity>          <dns value="localhost" />        </identity>      </endpoint>    </client>    <behaviors>      <endpointBehaviors>        <behavior name="ManagementServiceBehaviour">          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>        </behavior>          <behavior name="restbehavior">          <webHttp/>        </behavior>      </endpointBehaviors>            <serviceBehaviors>        <behavior>          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>          <!-- 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="true"/>          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>        </behavior>      </serviceBehaviors>    </behaviors>    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />  </system.serviceModel> <system.webServer>    <modules runAllManagedModulesForAllRequests="true"/>  </system.webServer>  <appSettings>    <!--Funcion Seguridad-->    <add key="user" value="USRSEG"/>    <add key="pass" value="usrseg"/>    <!--Ruta del Archivo Bindings-->    <add key="rutaArchivoBindings" value="D:\Discovery\Bindings.txt"/>        <!--Bindings Address-->    <add key="InterfacesWeb" value="ServiceAgents.InterfacesWeb"/>    <add key="Interface" value="ServiceAgents.Interfaces"/>    <add key="Comercios" value="ServiceAgents.Comercios"/>    <add key="Consultas" value="ServiceAgents.Consultas"/>    <add key="Operaciones" value="ServiceAgents.Operaciones"/>    <add key="Terminales" value="ServiceAgents.Terminales"/>        <!--Carga Masiva - Información de los servidores-->    <add key="NombreServidorWebOrigen" value="SERVIDORWEBORIGEN" />    <add key="NombreServidorLinuxBatch" value="SERVIDORLINUXBATCH" />    <!--Carga Archivo Cambios Masivos-->    <add key="CodigoProcesoCargaCambioMasivo" value="CMCM" />    <!--Sftp-->    <add key="SftpServidor" value="10.118.252.243" />    <add key="SftpPuerto" value="22" />    <add key="SftpUsuario" value="sgcidesa" />    <add key="SftpRutaArchivoDestino" value="/home/sgcidesa/file_in/" />    <add key="SftpRutaArchivoDescarga" value="/home/sgcidesa/file_out/" />        <add key="RutaArchivoOrigenCambiosMasivos" value="C:\FTPs\LocalUser\sgci\file_in\" />    <add key="RutaArchivoCargaCambiosMasivos" value="C:\FTPs\LocalUser\sgci\file_out\" />    </appSettings>  <secureSettings>    <add key="SftpPassword" value="desa" />  </secureSettings> </configuration>

This is the app.config of the client:

<?xml version="1.0" encoding="utf-8" ?><configuration>  <system.serviceModel>    <bindings>      <wsHttpBinding>        <binding name="InterfacesWeb" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">          <security mode="None" />        </binding>      </wsHttpBinding>    </bindings>    <client>      <endpoint address="http://localhost:1725/InterfacesWeb.svc" binding="wsHttpBinding"        bindingConfiguration="InterfacesWeb" contract="InterfaceServiceReference.IInterfacesWeb"        name="InterfacesWeb" />    </client>    <behaviors>      <endpointBehaviors>        <behavior name="ManagementServiceBehaviour">          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>                  </behavior>      </endpointBehaviors>    </behaviors>  </system.serviceModel></configuration>

This is the configuration of the reference:

image

I know that rest doesn't expose the metadata since it doesn't have WSDL.


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>