Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > WCF and null reference in Message contract

Reply
Thread Tools

WCF and null reference in Message contract

 
 
Scott Holman
Guest
Posts: n/a
 
      03-15-2007
I have defined a message contract (MsgRespData) and data
contract(DataResponse) listed below. The data contract has two fields
(System.String and System.Data.Dataset) and the message contract contains
the data contract. The service contract has a single method that returns
MsgRespData. When I test the service returning a instaniated DataSet in
DataResponse everything is fine. However, when the DataSet is null I
encounter the exception listed below. If I replace the DataSet in the
DataResponse contract with my own serializable class and return a null
reference the service works correctly.

Any insights would be appreciated. Thanks

************************************************** ************************
System.InvalidOperationException: No corresponding start element is open.
Server stack trace:
at System.Xml.XmlBaseReader.ReadEndElement()
at
System.ServiceModel.Dispatcher.OperationFormatter. DeserializeBodyContents(Message
message, Object[] parameters, Boolean isRequest)
at
System.ServiceModel.Dispatcher.OperationFormatter. DeserializeReply(Message
message, Object[] parameters)
at
System.ServiceModel.Dispatcher.ProxyOperationRunti me.AfterReply(ProxyRpc&
rpc)
at
System.ServiceModel.Channels.ServiceChannel.Handle Reply(ProxyOperationRuntime
operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(S tring action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[]
outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(S tring action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[]
outs)
at
System.ServiceModel.Channels.ServiceChannelProxy.I nvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.I nvoke(IMessage
message)

************************************************** ******************

[MessageContract]
public class MsgRespData
{
private WCFService1.DataContracts.DataResponse respDataField;

[MessageBodyMember(Order = 0)]
public WCFService1.DataContracts.DataResponse respData
{
get { return respDataField; }
set { respDataField = value; }
}

}

[DataContract(Namespace = "http://WCFService1.DataContracts/2007/03",
Name = "DataResponse")]
public partial class DataResponse
{
private MyClass DataCollectionField;
private System.String RespTextField;

[DataMember(EmitDefaultValue=true, IsRequired = false, Name =
"DataCollection", Order = 0)]
public MyClass DataCollection
{
get { return DataCollectionField; }
set { DataCollectionField = value; }
}
[DataMember(IsRequired = false, Name = "RespText", Order = 1)]
public System.String RespText
{
get { return RespTextField; }
set { RespTextField = value; }
}

}


 
Reply With Quote
 
 
 
 
Scott Holman
Guest
Posts: n/a
 
      03-15-2007
Previous post had incorrect definition of DataResponse:

[DataContract(Namespace = "http://WCFService1.DataContracts/2007/03",
Name = "DataResponse")]
public partial class DataResponse
{
private System.Data.DataSet DataCollectionField;
private System.String RespTextField;

[DataMember(EmitDefaultValue=true, IsRequired = false, Name =
"DataCollection", Order = 0)]
public System.Data.DataSet DataCollection
{
get { return DataCollectionField; }
set { DataCollectionField = value; }
}
[DataMember(IsRequired = false, Name = "RespText", Order = 1)]
public System.String RespText
{
get { return RespTextField; }
set { RespTextField = value; }
}

}


"Scott Holman" <> wrote in message
news:...
>I have defined a message contract (MsgRespData) and data
>contract(DataResponse) listed below. The data contract has two fields
>(System.String and System.Data.Dataset) and the message contract contains
>the data contract. The service contract has a single method that returns
>MsgRespData. When I test the service returning a instaniated DataSet in
>DataResponse everything is fine. However, when the DataSet is null I
>encounter the exception listed below. If I replace the DataSet in the
>DataResponse contract with my own serializable class and return a null
>reference the service works correctly.
>
> Any insights would be appreciated. Thanks
>
> ************************************************** ************************
> System.InvalidOperationException: No corresponding start element is open.
> Server stack trace:
> at System.Xml.XmlBaseReader.ReadEndElement()
> at
> System.ServiceModel.Dispatcher.OperationFormatter. DeserializeBodyContents(Message
> message, Object[] parameters, Boolean isRequest)
> at
> System.ServiceModel.Dispatcher.OperationFormatter. DeserializeReply(Message
> message, Object[] parameters)
> at
> System.ServiceModel.Dispatcher.ProxyOperationRunti me.AfterReply(ProxyRpc&
> rpc)
> at
> System.ServiceModel.Channels.ServiceChannel.Handle Reply(ProxyOperationRuntime
> operation, ProxyRpc& rpc)
> at System.ServiceModel.Channels.ServiceChannel.Call(S tring action,
> Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[]
> outs, TimeSpan timeout)
> at System.ServiceModel.Channels.ServiceChannel.Call(S tring action,
> Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[]
> outs)
> at
> System.ServiceModel.Channels.ServiceChannelProxy.I nvokeService(IMethodCallMessage
> methodCall, ProxyOperationRuntime operation)
> at System.ServiceModel.Channels.ServiceChannelProxy.I nvoke(IMessage
> message)
>
> ************************************************** ******************
>
> [MessageContract]
> public class MsgRespData
> {
> private WCFService1.DataContracts.DataResponse respDataField;
>
> [MessageBodyMember(Order = 0)]
> public WCFService1.DataContracts.DataResponse respData
> {
> get { return respDataField; }
> set { respDataField = value; }
> }
>
> }
>
> [DataContract(Namespace = "http://WCFService1.DataContracts/2007/03",
> Name = "DataResponse")]
> public partial class DataResponse
> {
> private MyClass DataCollectionField;
> private System.String RespTextField;
>
> [DataMember(EmitDefaultValue=true, IsRequired = false, Name =
> "DataCollection", Order = 0)]
> public MyClass DataCollection
> {
> get { return DataCollectionField; }
> set { DataCollectionField = value; }
> }
> [DataMember(IsRequired = false, Name = "RespText", Order = 1)]
> public System.String RespText
> {
> get { return RespTextField; }
> set { RespTextField = value; }
> }
>
> }
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Ajax Enabled WCF service and regular WCF? Cindy Lee ASP .Net 1 03-19-2010 05:59 PM
AJAX enabled WCF Service Vs Standard WCF Service Simon ASP .Net 0 10-13-2009 09:13 AM
VHDL and Verilog - 15 x Contract Engineers Required Urgently - Long Term Contract Specialist Verilog Engineers Roles VHDL 0 06-27-2007 01:09 PM
5 Ruby on Rails Developers - Contract to Hire or Contract - Washington, DC Job Hunter Ruby 0 09-06-2006 12:56 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57