.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Web service serialization exception

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :.NET Framework

Hi all, I am getting the following exception when attempt to make a web method call...


System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> There was an error generating the XML document. ---> Unable to cast object of type 'System.DBNull' to type 'System.String'.


I have created a Client Proxy  in .NET 2.0, a section of the WSDL is below...





View Complete Post

More Related Resource Links

Service Station: Serialization in Windows Communication Foundation


Windows Communication Foundation supports several serialization mechanisms and provides a simple, interoperable foundation for future service-oriented applications. Here Aaron Skonnard explains it all.

Aaron Skonnard

MSDN Magazine August 2006

Bug? : Sgen breaks web-service serialization

I am using the noaa weather web service and it works fine if I have not run sgen on the assembly. I have sgen disabled in the project settings and instead run it explicitly in the main build. I run sgen using the command: sgen /a:myassembly.dll /force /compiler:/keyfile:myassembly.snkThis creates an [assembly_name].XmlSerializers.dll and when running the application again, the same call to the web-service fails with the following exception. This is internal to the web-service code so I'm stuck for what to do other than not run sgen:System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'myassembly.gov.weather.www.productType' Key being added: 'myassembly.gov.weather.www.productType' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at System.Xml.Serialization.XmlSerializationWriter.AddWriteCallback(Type type, String typeName, String typeNs, XmlSerializationWriteCallback callback) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.InitCallbacks() at System.Xml.Serialization.XmlSerializationWriter.GetTypeEntry(Type t) at System.Xml.Serialization.XmlSerializationWriter.WriteReferencedElement(String name, String ns, Object o, Type ambientType)

Cash Drawer - Method Open threw an exception - Windows Service

Hi All, I'm getting the following exception while calling Open method of Cash Drawer object. Method Open threw an exception.  Could not read the device name key's default value, or could not convert the Programmatic ID it holds into a valid Class ID. Code:   class Class1 { CashDrawer _uniCashDrawer1 = null; DeviceInfo cashDrawerDevice1 = null; PosExplorer posExplorer = new Microsoft.PointOfService.PosExplorer();   public void ClaimCashDrawer() { cashDrawerDevice1 = posExplorer.GetDevice("CashDrawer", "testDrawer"); if (cashDrawerDevice1 != null) { _uniCashDrawer1 = posExplorer.CreateInstance(cashDrawerDevice1) as CashDrawer; if (_uniCashDrawer1 != null) { _uniCashDrawer1.StatusUpdateEvent += new StatusUpdateEventHandler(UniCashDrawer1_StatusUpdateEvent); _uniCashDrawer1.Open(); _uniCashDrawer1.Claim(0); _uniCashDrawer1.DeviceEnabled = true; } } } }   Tha above code works fine if you put the code in WindowsApplication in all POS systems. The same is working if you put the code in Windows Service in all other POS systems. The same is not working if you put the code in Windows Service in Aures Galeo POS systems.  Thanks in advance. Ramakrishnan S

While calling Web service gets exception "The request failed with HTTP status 401: Unauthorized"

Hi All, I created a ASP.NET web service, which was hosted on default visual studioserver, and on excecution of webservice it run .exe file which in turn update xml file. Now i hosted this webservice on IIS 6.0 server, and when i run the service, itfails to execute the exe.When i run it on debug mode, i never get any exception.Code...public string HelloWorld()    {        Process myProcess = new Process();        try        {            myProcess.StartInfo.UseShellExecute = false;            // You can start any process,             myProcess.StartInfo.FileName = @"E:\Projects\some.exe";            myProcess.StartInfo.CreateNoWindow = true;            myProcess.Start();            myProcess.Close();            myProcess.Dispose();            return "Suceess";         }&n

how can we show error in our application when exception occur in webs service

how can we show error in our application when exception occur in webs service

The requested service, 'http://localhost/MyServices/Test.svc' could not be activated Exception....

Hi I am using VS2010, WPF/WCF/.Net4, IIS 7, Windows 7. I am calling methods asynchronously, some times during execution I get the following errror.  The requested service, 'http://localhost/MyServices/Test.svc' could not be activated. See the server's diagnostic trace logs for more information. ======================== Server stack trace:    at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)    at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)    at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    at WSProxy.PatientService.IPatient.EndLoadPatientCardsInfosCompress(IAsyncResult result)    at WSProxy.PatientService.PatientClient.EndLoadPatientCardsInfosCompress(IAsyncResult result) ========================= Using BasiHttpBindi

WCF Service stops after throwing a unhandled exception :no user is logged on.

Hi All,       I have written a WCF service which is hosted as a Managed windows service. I consume this service in a web application. The service is built using a httpBasicBinding and security Mode ="none". I'm now getting the following exception, after which the service stops  "An unhandled exception ('System.ComponentModel.Win32Exception') occurred in CMMonitorService.exe [1812]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on." I had tried changing the security mode to Transport/Message. with windows credential then I get a access to the path denied error. Can anyone provide hint on what am I missing and what would be the appropriate security mode and client credential to use along with basichttpBinding?

RIA Service Serialization of POCOs

Hi, I have an object graph that I'm trying to persist while it's in an interim state.  I don't want to put the data in the true tables, so I'm serializing the graph and storing it in a separate table.  I'm using WCF/RIA services (v.1.0) to link my Silverlight (v.4) client with my back-end server (.NET v.4 with Entity Framework).  I'm using POCOs instead of entities on the back-end. I was able to decorate all of the members of my object graph with the [DataMember] attribute as well as decorate the classes with [DataContract].  When these POCOs are copied to the client project the [DataMember] attributes are missing from the child collections.  So when I serialize the graph (on the client) the children are missing.  I have also tried to send the graph to the server and serialize it there, but the children are missing when the graph gets to the service method.  On a side-note, persisting the graph into its set of tables works fine. I've tried this from numerous angles and cannot figure out how to get this working.  Any suggestions or alternatives would be greatly appreciated.  

Accessing a published web service gives null ref exception. Won't occur in test though?

I have an Asp.net web service that I created using Visual Studio 2005. I can acess the web service in my testenvironment, call methods and return data as expected. If this web service is published to the outside world (Outside of the company firewall), it will return a null reference exception. Does anyone have any idea why this might be happening? The same code is being used,against thesame database. The only difference is that the published website is giving back the null reference exception. If I type in the URL for the web service "https://secure.theSiteGeist.com/wsIndigo.asmx" a list of methods forthe web service is displayed in my browser. Yet if I try and call any methods on the web service I getback the null reference exception. Note that the URL I posted above is not the real name of my web service, but isjust used for reference sake.

SharePoint 2010 Excel Service Exception

SharePoint 2010 Excel Service Exception   I created Windows Form Application in Visual Studio 2010. I added Service Reference: http://<SharePoint _Server_Name>/_vti_bin/ExcelService.asmx. The code line: ExcelContract.XLWebService.ArrayOfAnyType returnData =              proxy.GetRangeA1(sessionID, sheetName, nameRange, false, out wsStatus);     throws exception: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/office/excel/server/webservices:GetRangeA1Response. The InnerException message was 'Error in line 1 position 361. Element 'http://schemas.microsoft.com/office/excel/server/webservices:anyType' I have the following app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration>     <system.serviceModel>         <bindings>             <basicHttpBinding>                 <binding name="ExcelServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"             

WF Service and Silverlight Cross domain exception

Hi I have created a workflow service (xamlx) and hosted it on IIS. The web.config file of the service is: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="VacationRequestService"> <endpoint contract="IVacationEntry" binding="wsHttpBinding"/> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- 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="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests

How to propagate WCF service exception details to the client?


We are working on WCF service hosted in Sharepoint 2010 and need to propagate exception information from server to the client. Currently when exception happens on the server we get the following generic error message: “The server was unable to process the request due to an internal error. For more information about the error turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client.”


For standalone (not Sharepoint hosted) WCF web service there is web.config configuration file where IncludeExceptionDetailInFaults=”true” can be set. But when WCF service is hosted in SP 2010 using dynamic configuration with service factory (MultipleBaseAddressBasicHttpBindingServiceHostFactory) there are no configuration file and we are totally puzzled how and where can we set IncludeExceptionDetailInFaults=”true” to propagate exception details to the client.

Getting Error when trying to consume web service CX_ST_MATCH_ELEMENT:XSLT exception.System expected

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:n1="urn:sap-com:document:sap:rfc:functions" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl" />
  <wsp:UsingPolicy wsdl:required="true" />
  <wsp:Policy wsu:Id="BN_BN_zaae_dlg_list_bind">
    <saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" wsp:Optional="true" />
    <saptrnbnd:OptimizedXMLTransfer uri="http://ww

Exception handling in web service


I've written a web service and implented some exception handling withing my code. When I debug the services the exception handling works as planned, the catch clause handles the exception. The problem is that when I deploy to a production IIS 7 web server the exception handling in my code does not appear to be trapping any errors. It appears that IIS is trapping the errors and returns back a 500 error.

Is there a setting in web.config to prevent this from happening or is there some configuration change in II7 that need to happen to prevent my error handling from being overridden?


CreateDocument method in CMIS Object Service raising the Constraint Violation Exception


HI All,

Below are the code snippet for rasing the above exception like  "The operation violates a Repository- or Object-level constraint defined in the CMIS domain model. "


ObjectServicePortClient objectService = new TestCMISWinApp.ObjectService.ObjectServicePortClient("BasicHttpBinding_IObjectServicePort");

objectService.ClientCredentials.Windows.AllowNtlm =



Windows Service crash - catch exception


A windows service written in C# is intermittently crashing on a server. If I want to log the reason for crash, can I add try catch block in OnStop method?

will onStop  method get initiated on crashing?

protected override void OnStop()

EL Exception Handling block and WCF custom Service Fault Exception


I am currently working on a project to integrate WCF custom fault along with enterprise library exception block. 

I was following Guy Burstein's blog for doing this :


This example only shows mapping for message and id. The message is of string data type and id is Guid data type.

But what if I have some other custom fields in my custom Fault object in which I have a CategoryID of type string to which I need to map the id of type Guid ?

When I try to do the mapping and propogate it, I get the value as null. Is there some way I could convert the Guid to string type while doing the mapping in EL?


public class ServiceFault



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend