basquang™ on clouds

November 25, 2015

Transfer large data with WCF

Filed under: Uncategorized,WCF — basquang @ 3:16 PM
Tags:

[MSDN]: Introduction to Building Windows Communication Foundation Services

[MSDN]: Large Data and Streaming

[MSDN] Transferring large blobs of data with WCF

[MSDN]: Streaming Message Transfer

Transferring large files using WCF

File Transfer with WCF

WCF Streaming: Upload files over HTTP

Transferring large data over the wire using WCF

Passing Large Files in Windows Communication Foundation (WCF) using Streaming and TCP

MTOM vs. Streaming vs. Compression – Large attachments over WCF

Streaming Files (for Upload/Download) in WCF (Message Contracts)

 

November 10, 2015

Secure your WCF Web Services resource references

Filed under: Digital Signature,WCF — basquang @ 3:52 PM
Tags:

You want to secure your WCF web services, you want to sign digital signature on your web service here are some good references

[MSDN]: Using Message Contracts

[MSDN]How to: Set the ProtectionLevel Property

[VS Magazine] Security Considerations and Best Practices for WCF 4 Apps

[MSDN] Message Security with a Certificate Client

[MSDN] Message Security Certificate

[CodeProject] WCF Service Method Level Security using Message Contract

May 17, 2013

Update Single/Multiple Lookup field in SharePoint 2010 using WCF Data Services, REST API, C#

Filed under: SharePoint,WCF — basquang @ 11:03 AM

If you want to use SharePoint 2010 WCF Data Services to update SharePoint lookup field in a list; you need remember following things:

To update single Lookup field: Use Id to reference to the looked up list object to the target list object similar as the code below:

item.CompetencyId = competency.Id; //Add looked up list item object by ID
dc.UpdateObject(item);             //Update the target object
dc.SaveChanges();		      //Save changes from data context

 

To update a lookup field that allow multiple values: Use the AddLink(object source, string sourceProperty, object target) from datacontext with the System.Data.Services.Client.SaveChangesOptions.Batch mode similar as the code below:

//Add multiple link to the target list object
foreach(var competency in competencies)
	{
		dc.AddLink(item, "Competency", competency);
	}
dc.UpdateObject(item);               
//SaveChanges in batch mode
dc.SaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch);

 

Hope this help!

September 19, 2009

WCF và tính tương thích với ASP.NET

Filed under: WCF — basquang @ 2:59 AM

Một sự khác biệt to lớn giữa các Web Services truyền thống ASMX và WCF Services là khả năng kích hoạt của chúng. Với WCF các services có thể được kích hoạt thông qua các giao thức ngoài HTTP như net.tcp, net.pipe hoặc WAS (Windows Activation Service). Trong khi ASMX service chỉ có thể được kích hoạt thông qua HTTP, và do đó nó liên kết chặt chẽ với ASP.NET HTTP pipeline. Điều này khiến cho các WCF services trở nên khá linh hoạt và động lập trong quá trình triển khai. Chúng có thể được deploy ở IIS, Windows Services hoặc các host tự tạo. Ngay cả khi WCF service được triển khai trên môi trường IIS, bên trong một ASP.NET application thì nó cũng không phụ thuộc vào các features của ASP.NET. Chúng ta dễ dàng nhận thấy rằng, các features trong ASP.NET như:

  • Authentication
  • Url/File authorization
  • Impersonation
  • Session state
  • Request cache
  • Globalization
  • Custom HttpModules
  • Các features này thuộc về các thư viện HTTP:

  • System.Web.HttpApplication
  • System.Web.HttpContext
  • Các features này sẽ không có khả năng sử dụng nếu như chúng ta không thiết lập ASP.NET Compatible Mode cho WCF. Khi đó, với HttpContext, đối tượng Current là luôn luôn null trong WCF. Để sử dụng các features này trong WCF, chúng ta cấu hình ASP.NET Compatible mode cho WCF. WCF cung cấp khả năng hỗ trợ ASMX thông qua các phương thức hosting khác nhau

    • Mixed Transports Mode
    • ASP.NET compatibility mode

    Để thiết lập ASP.NET Compatible Mode, chúng ta tham khảo hướng dẫn trên MSDN:

    http://msdn.microsoft.com/en-us/library/aa702682.aspx

    Reference: ASP.NET Compatibility Mode

    August 18, 2009

    WCF and ASP.NET Membership error: An error occurred when verifying security for the message

    Filed under: WCF — basquang @ 11:03 AM

    System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrect
    ly secured fault was received from the other party. See the inner FaultException
    for the fault code and detail. —> System.ServiceModel.FaultException: An erro
    r occurred when verifying security for the message.
       — End of inner exception stack trace —

     

    I got this error message when deploy and use WCF with ASP.NET Membership over Internet. My WCF service use wsHttpBinding and Security mode = TransportWithMessageCredential. My machine for test are Windows 7, Visual Studio 2008 SP1, SQL Express 2005. I’ve spent more time to looking for solution. After that, It’s worked fine! Here are work around and solutions

    Open Event Viewer

    Following error was appeared:

    Failed to generate a user instance of SQL Server due to failure in retrieving the user’s local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed. [CLIENT: <local machine>]

    clip_image002[6]

    This is the root of problem.

    Solution:

    Add following account to SQL Server

    – IIS APPPOOL\DefaultAppPool

    – Local System

    – Local Services

    2. Open the Application Pool of your website used.

    clip_image003

    You see: Identity: ApplicationPoolIdentity (Windows 7 IIS)

    clip_image004

    3. Change the Identity to one of other account then iisreset

    clip_image005

    Hope this help!

    May 14, 2009

    WCF và nguyên lý ABC

    Filed under: WCF — basquang @ 5:11 AM

    wcf_concept_map

    Blog at WordPress.com.