Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Wednesday, November 03, 2010

WCF Support for jQuery

Support for 'jQuery-friendly' WCF services has now been added to Visual Studio 2010 via CodePlex: http://tomasz.janczuk.org/2010/10/wcf-support-for-jquery-on.html

Monday, November 01, 2010

WCF Message Logging Configuration

How to configure Message Logging in WCF:

<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>

<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false"
maxMessagesToLog="3000"
maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>
See: http://msdn.microsoft.com/en-us/library/ms730064.aspx

WCF Timeouts Explained

An explanation of where and why to use the WCF Timeout configurations:

Client side:

  • SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.
  • OpenTimeout and CloseTimeout are used when opening and closing channels (when no explicit timeout value is passed).
  • ReceiveTimeout is not used.

Server side:

  • Send, Open, and Close Timeout same as on client (for Callbacks).
  • ReceiveTimeout is used by ServiceFramework layer to initialize the session-idle timeout.

Source: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/

Tuesday, September 14, 2010

WCF - Streaming Large Data

I've been re-developing our web service for sending transmitting files to better handle large files. It was using an ASP.NET ASMX web service to send a byte[] and now it is using the WCF Streamed transferMode to send a MessageContract containing a Stream via MTOM! Sounds very grand doesn't it...

Found the following MSDN resources very helpful:

Hosting and Consuming WCF Services
System.ServiceModel Namespace

Large Data and Streaming
Streaming Message Transfer
How to: Enable Streaming
MTOM Encoding
Using Data Contracts
Using Message Contracts

P.S. An annoyance whilst trying to work out why the Streamed transferMode was not working was that the Visual Studio 2010 in-built web server could not handle it. As soon as it was deployed to IIS it worked fine!

Wednesday, September 01, 2010

Configuring a proxy-server for WCF

To configure a proxy for a specific client/service endpoint, you can configure this on the binding that is used by the endpoint, eg:

<basicHttpBinding>
<binding name="MyClientBinding" proxyAddress="http://gateway:8080" useDefaultWebProxy="false">
</binding>
</basicHttpBinding>

Source: http://blogs.infosupport.com/blogs/porint/archive/2007/08/14/Configuring-a-proxy_2D00_server-for-WCF.aspx

Friday, August 20, 2010

Detect Client IP in WCF 3.5

Handy litte post showing how to detect the client IP in WCF (3.5 or 4.0).

http://nayyeri.net/detect-client-ip-in-wcf-3-5

Wednesday, February 17, 2010

Consuming SharePoint Web Services with WCF

I had a few problems getting the WCF config correct to call SharePoint web services so thought I would share the solution that worked for me:

ClientCredentials - client credentials are required

using (ListsSoapClient proxy = new ListsSoapClient())
{
proxy.ClientCredentials.Windows.ClientCredential = new NetworkCredential();
...
}

Web.config or app.config - NTLM required

 <system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap" maxReceivedMessageSize="9999999">
<readerQuotas maxBytesPerRead="9999999"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://corporate-portal.ccc/_vti_bin/Lists.asmx" binding="basicHttpBinding" bindingConfiguration="ListsSoap" contract="SPLists.ListsSoap" name="ListsSoap"/>
</client>
</system.serviceModel>

Thursday, February 11, 2010

Using WCF to call a Web Service via a Web Proxy

I was pleasantly surprised at how easy this proved to be:

WebRequest.DefaultWebProxy = new WebProxy("http://1.1.1.1:80")