Parse Error, no assembly associated with Xml key.

Y

yoyo yoyo

In our scenario, MQ Broker calls C#.Net Webservice void method which
takes xml string. And inside the webservice method we are trying to
deserialize SOAP message into XML using soapformatter and we are
getting Parse Error, no assembly associated with Xml key.

On the MQ Broker SOAP payload as response configured as
SOAPAction:http://mydomain/abc/webservicemethod Content-Type:text/xml.


Any ideas, help appreciated.
 
P

Peter Duniho

In our scenario, MQ Broker calls C#.Net Webservice void method which
takes xml string. And inside the webservice method we are trying to
deserialize SOAP message into XML using soapformatter and we are
getting Parse Error, no assembly associated with Xml key.

On the MQ Broker SOAP payload as response configured as
SOAPAction:http://mydomain/abc/webservicemethod Content-Type:text/xml.

Any ideas, help appreciated.

Either your XML is getting corrupted or you have failed to include the
assembly that defines the type(s) being serialized in the project trying
to deserialize the data.

If I had to guess (and lacking a concise-but-complete code example from
you, I do), I'd guess it's the latter.

If you want a better answer, you need to post a concise-but-complete code
example that reliably demonstrates the problem.

Pete
 
Y

yoyo yoyo

Thanks Peter the for the reply.


Here is an example of a SOAP message as an actual XML document:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<h:from xmlns:h="http://www.ets-software.com/
Header">[email protected]</h:from>
</soap:Header>
<soap:Body>
<w:GetMainIdentity xmlns:w="http://www.ets-software.com/Authors/">
<w:nickname>XSLT-Author</w:nickname>
</w:GetMainIdentity>
</soap:Body>
</soap:Envelope>


I stored the above soap message into file named DataFile.soap, used
the following C# scriptlet


XmlDocument doc = new XmlDocument();
FileStream fs = new FileStream(@"c:\DataFile.soap",
FileMode.Open);
try
{
SoapFormatter formatter = new SoapFormatter();
doc = (XmlDocument)formatter.Deserialize(fs);
}


Here I am experiencing Parse Error, no assembly associated with Xml
key w GetMainIdentity. How can I achieve assembly that define(s) the
type being serialized?
 
P

Peter Duniho

[...]
try
{
SoapFormatter formatter = new SoapFormatter();
doc = (XmlDocument)formatter.Deserialize(fs);
}


Here I am experiencing Parse Error, no assembly associated with Xml
key w GetMainIdentity. How can I achieve assembly that define(s) the
type being serialized?

Have your project reference an assembly that does provide the association
with "GetMainIdentity".

If the SOAP message isn't being generated by such an assembly in the first
place, you may find it difficult or impossible to accomplish that. In
that case, the answer is that you simply cannot use the
SoapFormatter.Deserializer() method with this data.

Pete
 
Y

yoyo yoyo

FileStream fs = new FileStream(@"c:\DataFile.soap",
FileMode.Open);
try
{
XmlSerializer ser = new XmlSerializer(typeof
(XmlDocument));
idoc = (XmlDocument)ser.Deserialize(fs);
}


Basically MQ Broker sending XML stream in SOAP, I tried using
XmlSerializer as mentioned above, it is displaying the content as it
is, not stripping the Namespaces. Thats why I tried SOAPFormatter
class, its not useful either, do you know what to use in my scenario?

Thanks in advance.
 
P

Peter Duniho

FileStream fs = new FileStream(@"c:\DataFile.soap",
FileMode.Open);
try
{
XmlSerializer ser = new XmlSerializer(typeof
(XmlDocument));
idoc = (XmlDocument)ser.Deserialize(fs);
}


Basically MQ Broker sending XML stream in SOAP, I tried using
XmlSerializer as mentioned above, it is displaying the content as it
is, not stripping the Namespaces. Thats why I tried SOAPFormatter
class, its not useful either, do you know what to use in my scenario?

No. I'm not familiar with "MQ Broker", nor have you provided a
concise-but-complete code example that reliably demonstrates the problem.

You could hope for someone else to figure out exactly what your scenario
is, but given the lack of alternate answers provided so far, I suspect
we're all in the same boat: we don't really fully comprehend the source of
the data or why you'd expect the XmlSerializer.Deserializer() method to
successfully deserialize the data.

The lack of knowing the specific technologies is often not a major
impediment, but only when the person asking the question is able to
provide enough information to fill in those details. Usually that entails
the questioner providing a concise-but-complete code example that reliably
demonstrates the problem, so that there are no ambiguities at all about
the question.

Pete
 
F

Family Tree Mike

yoyo said:
FileStream fs = new FileStream(@"c:\DataFile.soap",
FileMode.Open);
try
{
XmlSerializer ser = new XmlSerializer(typeof
(XmlDocument));
idoc = (XmlDocument)ser.Deserialize(fs);
}


Basically MQ Broker sending XML stream in SOAP, I tried using
XmlSerializer as mentioned above, it is displaying the content as it
is, not stripping the Namespaces. Thats why I tried SOAPFormatter
class, its not useful either, do you know what to use in my scenario?

Thanks in advance.

The Soap document can be treated as an xml document. Load that into an
XmlDocument object, then find the element <soap:Body>. That element
contains the text for the document you are trying to get, I believe. I
don't think you deserialize anything to get an XmlDocument. They are
just passing the xml as a string.

static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("XMLFile1.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("soap",
"http://schemas.xmlsoap.org/soap/envelope/");
XmlElement e = (XmlElement)
doc.DocumentElement.SelectSingleNode("soap:Body", nsmgr);
Console.WriteLine(e.InnerXml);
XmlDocument docInner = new XmlDocument();
docInner.LoadXml(e.InnerXml);
Console.WriteLine("Done...");
Console.ReadLine();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top