Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

basicHttpBinding & webHttpBinding together

I'm developing a WCF service with C# and .NET Framework 4.0.

I'm using webHttpBinding to do this:

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Bare,
    UriTemplate = "filteredOrders/")]
OrderContract[] GetOrders(IdsMessage msg);

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Bare,
    UriTemplate = "completeFilteredOrders/")]
OrderContract[] LoadCompleteFilteredOrders(IdsMessage msg);

But now I need to send images to that Web Service using streamming and I need to add basicHttpBinding to do it.

How can I do that a new [OperationContract] to this WCF Web Service that uses basicHttpBinding?

Sorry, I'm very new on WCF development.

By the way, this is my Web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="EReportService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="EReportService.IRestServiceImpl" behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="2097152" maxBufferSize="2097152" transferMode="Streamed"/>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>       
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <connectionStrings>

  </connectionStrings>
</configuration>
like image 422
VansFannel Avatar asked Nov 28 '12 18:11

VansFannel


People also ask

What is a BasicHttpBinding?

BasicHttpBinding is suitable for communicating with ASP.NET Web Service (ASMX) based services that conform to the WS-Basic Profile that conforms with Web Services. This binding uses HTTP as the transport and text/XML as the default message encoding. Security is disabled by default.

What is BasicHttpBinding and WsHttpBinding?

Primarily BasicHttpBinding is designed to exchange SOAP over HTTP(s) only, just like old ASMX or . net web services and supports the WS-I BasicProfile. WsHttpBinding supports the advanced WS-* specification which includes WS-Addressing and WS-Security etc.


1 Answers

Just create another endpoint using a different address (two endpoints cannot share the same address) - you can modify the existing OperationContract to create the non-RESTful methods.

 <system.serviceModel>
    <services>
      <service name="EReportService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="EReportService.IRestServiceImpl" behaviorConfiguration="web">
        </endpoint>
        <endpoint address="soap" binding="basicHttpBinding" contract="EReportService.IRestServiceImpl" >
        </endpoint>
      </service>
    </services>
 </system.serviceModel>
like image 167
SliverNinja - MSFT Avatar answered Sep 19 '22 06:09

SliverNinja - MSFT