Ask a Question related to ASP.NET Web Services, Design and Development.
-
Emre Aydinceren #1
DataTable parameter of a WebMethod?
DataTable is not serializable, you have to put them in a
dataset.
DataTable object to it.>-----Original Message-----
>Hey, here is my simple WebMethod. I'm passing aI visit the .asmx>
> [WebMethod()]
> public string TestMethod(DataTable dt)
> {
> return dt.ToString();
> }
>
>Quite to my surprise, ASP.NET spew out errors to me whencan't pass in a>file.
>
>I just got no idea what these messages mean and why I------------------->DataTable while I can pass in a DataSet.
>
>Help me!
>Server Error in '/MyWebApps/WebApplication1' Application.
>---------------------------------------------------------System.ComponentModel.MarshalByValueComponent.Site>----
>
>Cannot serialize memberinterface.>of type System.ComponentModel.ISite because it is anexecution of the>Description: An unhandled exception occurred during themore information>current web request. Please review the stack trace forserialize member>about the error and where it originated in the code.
>
>Exception Details: System.NotSupportedException: Cannottype>System.ComponentModel.MarshalByValueComponent.Sit e ofexecution of the>System.ComponentModel.ISite because it is an interface.
>
>Source Error:
>
>
> An unhandled exception was generated during theand location of the>current web request. Information regarding the origintrace below.>exception can be identified using the exception stacktype>
>
>Stack Trace:
>
>
>[NotSupportedException: Cannot serialize member
>System.ComponentModel.MarshalByValueComponent.Sit e of(Type type, Boolean>System.ComponentModel.ISite because it is an interface.]
> System.Xml.Serialization.TypeScope.ImportTypeDesctype, MemberInfo>canBePrimitive, MemberInfo memberInfo) +1283
> System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e(PropertyInfo>source, Boolean directReference) +50
> System.Xml.Serialization.StructModel.GetPropertyMo del(MemberInfo memberInfo)>propertyInfo) +54
> System.Xml.Serialization.StructModel.GetFieldModelctLikeMapping(Struc>+88
>
>System.Xml.Serialization.XmlReflectionImporter.Im portStructLikeMapping(Struc>tModel model, String ns) +1534
>
>System.Xml.Serialization.XmlReflectionImporter.Im portStruMapping(TypeModel>tModel model, String ns) +662
>
>System.Xml.Serialization.XmlReflectionImporter.Im portTypedataType, Boolean repeats)>model, String ns, ImportContext context, Stringreflecting type>+440
>
>[InvalidOperationException: There was an errorMapping(TypeModel>'System.Data.DataTable'.]
>
>System.Xml.Serialization.XmlReflectionImporter.Im portTypedataType, Boolean repeats)>model, String ns, ImportContext context, StringssorMapping(MemberM>+1059
>
>System.Xml.Serialization.XmlReflectionImporter.Im portAcceString ns, Type>apping accessor, FieldModel model, XmlAttributes a,erMapping(XmlReflec>choiceIdentifierType) +8238
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMembXmlReflectionMember[]>tionMember xmlReflectionMember, String ns,ersMapping(XmlRefle>xmlReflectionMembers) +795
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMembhasWrapperElement)>ctionMember[] xmlReflectionMembers, String ns, Booleanreflecting 'dt'.]>+300
>
>[InvalidOperationException: There was an errorersMapping(XmlRefle>
>System.Xml.Serialization.XmlReflectionImporter.Im portMembhasWrapperElement)>ctionMember[] xmlReflectionMembers, String ns, BooleanersMapping(String>+607
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMembBoolean>elementName, String ns, XmlReflectionMember[] members,Mapping(XmlReflecti>hasWrapperElement) +108
>
>System.Web.Services.Protocols.SoapReflector.Impor tMemberssoapImporter, Boolean>onImporter xmlImporter, SoapReflectionImporteruse, SoapParameterStyle>serviceDefaultIsEncoded, Boolean rpc, SoapBindingUseBoolean>paramStyle, String elementName, String elementNamespace,validate) +169>nsIsDefault, XmlReflectionMember[] members, Boolean(LogicalMethodInfo>
>System.Web.Services.Protocols.SoapReflector.Refle ctMethodxmlImporter,>methodInfo, Boolean client, XmlReflectionImporter+1915>SoapReflectionImporter soapImporter, String defaultNs)can not be>
>[InvalidOperationException: Method Service1.TestMethod2(LogicalMethodInfo>reflected.]
>
>System.Web.Services.Protocols.SoapReflector.Refle ctMethodxmlImporter,>methodInfo, Boolean client, XmlReflectionImporter+5415>SoapReflectionImporter soapImporter, String defaultNs)System.Web.Services.Description.SoapProtocolReflec tor.Refl>
ectMethod()Binding(ReflectedBi>+130
>
>System.Web.Services.Description.ProtocolReflector .ReflectSystem.Web.Services.Description.ProtocolReflector. Reflect>nding reflectedBinding) +1818
>
() +506or.ReflectInternal(>
>System.Web.Services.Description.ServiceDescriptio nReflectSystem.Web.Services.Description.ServiceDescription Reflecto>ProtocolReflector[] reflectors) +495
>
r.Reflect(TypeSystem.Web.Services.Protocols.DocumentationServerT ype..cto>type, String url) +112
>
r(Type type,System.Web.Services.Protocols.DocumentationServerP rotocol.>String uri) +158
>
Initialize()System.Web.Services.Protocols.ServerProtocolFactor y.Create>+268
>
(Type type,response, Boolean&>HttpContext context, HttpRequest request, HttpResponseSystem.Web.Services.Protocols.ServerProtocolFactor y.Create>abortProcessing) +106
>
>[InvalidOperationException: Unable to handle request.]
>
(Type type,response, Boolean&>HttpContext context, HttpRequest request, HttpResponsereGetHandler(Type>abortProcessing) +205
>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.CoHttpResponse response) +82>type, HttpContext context, HttpRequest request,reGetHandler(Type>
>[InvalidOperationException: Failed to handle request.]
>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.CoHttpResponse response) +154>type, HttpContext context, HttpRequest request,tHandler(HttpContex>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.Gecontext, String>t context, String verb, String url, String filePath) +94
> System.Web.HttpApplication.MapHttpHandler(HttpCont extuseAppConfig) +699>requestType, String path, String pathTranslated, Booleantion+IExecutionStep>
>System.Web.MapHandlerExecutionStep.System.Web.Htt pApplicastep, Boolean&>..Execute() +95
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep------------------->completedSynchronously) +173
>
>
>
>
>
>---------------------------------------------------------Version:1.1.4322.573; ASP.NET>----
>
>Version Information: Microsoft .NET Framework>Version:1.1.4322.573
>
>
>.
>Emre Aydinceren Guest
-
WebMethod signature which takes SortedList as parameter??
SortedList is a .NET class and shouldn't be used as a parameter to a Webmethod. I just posted earlier today discussing why things like this aren't... -
WebMethod + MaxOccurs for input parameter; possible?
Good afternoon everyone, I have a WebMethod function (VB .NET) that receive a parameter (Order #). I would like to be able to change my function... -
Is it possible to return just a DataTable from a WebMethod, instead of DataSet?
Hi all, I just want to make sure i'm not doing anything stupid, but it seems to me that its not possible to return a simple datatable from a... -
DataTable as parm to a WebMethod function?
According to MS, DataTable cannot be passed or returned by a Web Service. Try using DataSet instead. Aleksey -
Adding an XmlNode parameter to the HelloWorld WebMethod
I've added an XmlNode as a parameter to the HelloWorld WebMethod. The automaticall generated WSDL would leave one to believe that any well-formed...



Reply With Quote

