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

Wednesday, February 6, 2013

Invoking a web service returning ISO-8859-1 encoded data with BizTalk Server 2010


The TextMessageEncodingBindingElement of WCF supports only the UTF-8, UTF-16 and Big Endean Unicode encodings. If the web service returns response in some other encoding e.g. ISO-8859-1 need to be consumed in BizTalk Server 2010 then the following error get logged in the event viewer:

System.ServiceModel.ProtocolException: The content type text/xml of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.

I have published the solution to above problem along with the code at MSDN.

Cheers
Rohit Sharma


Monday, July 4, 2011

Error: "Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies."

Moving the original post

When trying to browse my WCF service using .Net Framework 4.0 and hosted in IIS 6.0 I was getting this error in the event viewer.

Event Type:         Error
Event Source:     ASP.NET 4.0.30319.0
Event Category:  None
Event ID:            1325
Description:
Failed to initialize the AppDomain:/LM/W3SVC/1381374284/Root/RetrieveDataService
Exception: System.IO.FileLoadException
Message: Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.
StackTrace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
   at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
   at System.Activator.CreateInstance(AppDomain domain, String assemblyName, String typeName)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

Resolution
Because the Application Pool was using the identity NETWORK SERVICE so I had to give the IIS_WPG group (which contains NETWORK SERVICE) read/write access to my web root directory.

Cheers
Rohit Sharma

Error: “The document specification ‘...’ from assembly ‘...’ failed to load.”

Moving the original post
In BizTalk server 2010 I published an orchestration as WCF service using the ‘BizTalk WCF Service Publishing Wizard’. The orchestration gets published successfully. After configuring and starting the orchestration when trying to consume the WCF service, I was getting following errors:
In the client code consuming the WCF service exception was
The server was unable to process the request due to an internal error.  …
In the event log on the BizTalk machine:

Error:

There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML disassembler" Receive Port:
The document specification ‘..’  from assembly ‘..’ failed to load. Verify the schema for this document specification is deployed and is in the Global Assembly Cache.

Warning:

The adapter "WCF-WSHttp" raised an error message. Details "System.TimeoutException: The service's security session did not receive a 'close' message from the client within the configured timeout (00:00:10)….
I verified that the assembly containing schema was deployed to GAC and I was facing the same issue after increasing the timeout value for Open,Send and Close for WS-Http receive location.

Solution

Based on the error received in the client code I tried to investigate the WCF service deployment in IIS 7. The actual problem was the application pool used for WCF service was using .Net Framework v2.0.50727 after changing it to v4.0.30319 the issue got resolved. This issue occur because the path of GAC has been changed in the .Net Framework 4.0.

Cheers
Rohit Sharma

Error: “Root element is missing”


Moving the original post

In BizTalk 2010 I created a WCF-WSHttp receive location. Then using the BizTalk WCF Service Publishing Wizard I created a meta data only endpoint, based on my WCF-WSHttp receive location and I added the required schema. The WCF service was created successfully. The application Pool used for this WCF service was configured using the identity having access to BizTalk databases.
When I tried to see the WSDL I got the exception: “Root element is missing”.

To resolve this issue I have to do the following two extra steps:

1.  Added the account used to configure the application pool to BizTalk Server Administrators group.

2. Added the following line to the Web.Config of WCF services created with the BizTalk WCF Service Publishing Wizard.
<system.web>
          <trust level="Full" originUrl="" />
<system.web>
For additional information refer to this MSDN link.

Cheers
Rohit Sharma

Thursday, June 30, 2011