cyclonebri
Well-known member
Hey everybody,
Heres a real fun one that Ive been fighting for about a day now so Id like to throw it out to see if anyone has a solution to what is happening here.
I have developed an XMLWeb service, which correctly queries the data that I need and using xpath manipulates the data into the proper form and then places the new data into a new XmlDocument.
To instantiate this procedure, I pass an object from the client by ref to the webservice. The object is defined as a class on the webservice, however there is no coding inside the class (the webservice class is basically a struct, as this is how I learned to do this). Everything works as it should and the pass is successful. Inside the class (called cDocument) the cDocument object contains two XmlDocuments, UserSideData, and ServerSideData. These two documents work like documents, store data like documents and even say they are going to return documents, but they dont. When myService is added as a web reference to my client, the two document object variables within the class are showing up as XmlNodes, not XmlDocuments. When I try to access them, then it tells me that there are invalid casts or throws a soap exception.
I can send data to the web service and it works fine, but returning the data in the referenced object is where Im having the problem. Does anyone have any thoughts?
Here is some code that Im using:
[CS]
//cdocument
namespace XMLDataSync
{
/// <summary>
/// Summary description for cDocument.
/// </summary>
public class cDocument
{
public System.Xml.XmlDocument m_UserDocument;
public System.Xml.XmlDocument m_ServerDocument;
public cDocument()
{
}
}
}
//***********************************************
//in the web service itself:
[WebMethod]
public void SynchronizeData(ref cDocument myCDocument)
{
m_LocalcDocument = myCDocument;
//sync algortihm runs here, using the myCDocument and comparing to the server data.
//once this is run the cDocument m_ServerDocument will be the returning value that will be used to resync on the client side
//for now I am just returning the original document, until I get this working I cannot move forward
myCDocument.m_ServerDocument = myCDocument.m_UserDocument;
}
//***************************************************
//ClientSideCode
myProject.SyncWebRef.cDocument myCDocument= new cDocument();
//I already have a document ready to send for the user data before doing this
myCDocument.m_UserDocument = myDocument;
myProject.SyncWebRef.XMLDataSync x_sync_svc = new XMLDataSync();
x_sync_svc.Synchronize(ref myCDocument);
//****************HERE IS THE PROBLEM:*****************
//This will cause an error:
System.Xml.XmlDocument myDoc2 = myCDocument.m_ServerDocument;
//even though this should work it doesnt, as the client is thinking that myCDocument.m_ServerDocument and myCDocument.m_UserDocument are xmlnodes, not xmldocuments.
[/CS]
Thanks in advance for any help!
Brian
**Edit**
After further testing I have realized that I cant send an xmldocument either. I can however do simple objects like strings or integers and they work fine. I am thinking something about the document is getting lost through the passing between the client and the service and that is why it is a node, not a document. Any help is still greatly appreciated. Thanks!
Heres a real fun one that Ive been fighting for about a day now so Id like to throw it out to see if anyone has a solution to what is happening here.
I have developed an XMLWeb service, which correctly queries the data that I need and using xpath manipulates the data into the proper form and then places the new data into a new XmlDocument.
To instantiate this procedure, I pass an object from the client by ref to the webservice. The object is defined as a class on the webservice, however there is no coding inside the class (the webservice class is basically a struct, as this is how I learned to do this). Everything works as it should and the pass is successful. Inside the class (called cDocument) the cDocument object contains two XmlDocuments, UserSideData, and ServerSideData. These two documents work like documents, store data like documents and even say they are going to return documents, but they dont. When myService is added as a web reference to my client, the two document object variables within the class are showing up as XmlNodes, not XmlDocuments. When I try to access them, then it tells me that there are invalid casts or throws a soap exception.
I can send data to the web service and it works fine, but returning the data in the referenced object is where Im having the problem. Does anyone have any thoughts?
Here is some code that Im using:
[CS]
//cdocument
namespace XMLDataSync
{
/// <summary>
/// Summary description for cDocument.
/// </summary>
public class cDocument
{
public System.Xml.XmlDocument m_UserDocument;
public System.Xml.XmlDocument m_ServerDocument;
public cDocument()
{
}
}
}
//***********************************************
//in the web service itself:
[WebMethod]
public void SynchronizeData(ref cDocument myCDocument)
{
m_LocalcDocument = myCDocument;
//sync algortihm runs here, using the myCDocument and comparing to the server data.
//once this is run the cDocument m_ServerDocument will be the returning value that will be used to resync on the client side
//for now I am just returning the original document, until I get this working I cannot move forward
myCDocument.m_ServerDocument = myCDocument.m_UserDocument;
}
//***************************************************
//ClientSideCode
myProject.SyncWebRef.cDocument myCDocument= new cDocument();
//I already have a document ready to send for the user data before doing this
myCDocument.m_UserDocument = myDocument;
myProject.SyncWebRef.XMLDataSync x_sync_svc = new XMLDataSync();
x_sync_svc.Synchronize(ref myCDocument);
//****************HERE IS THE PROBLEM:*****************
//This will cause an error:
System.Xml.XmlDocument myDoc2 = myCDocument.m_ServerDocument;
//even though this should work it doesnt, as the client is thinking that myCDocument.m_ServerDocument and myCDocument.m_UserDocument are xmlnodes, not xmldocuments.
[/CS]
Thanks in advance for any help!
Brian
**Edit**
After further testing I have realized that I cant send an xmldocument either. I can however do simple objects like strings or integers and they work fine. I am thinking something about the document is getting lost through the passing between the client and the service and that is why it is a node, not a document. Any help is still greatly appreciated. Thanks!
Last edited by a moderator: