Web service avec un paramètre d'entrer XML
Bonjour,
J'ai réalisé un web service qui prend en paramètre d'entrer un XML :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
[WebMethod]
public string GetFirstName(XmlDocument mm)
{
// Create a new XmLDocument object.
XmlDocument XmlDocumentObject = new XmlDocument();
// Load the XmlNode into the XmlDocument object.
XmlDocumentObject.LoadXml(mm.OuterXml);
// Find the first name of the author.
XmlNodeList XmlNodeListObj = XmlDocumentObject.GetElementsByTagName("first-name");
// Return the first name.
return XmlNodeListObj[0].ChildNodes[0].Value;
} |
Sauf que quand je fais appel à mon web servie :
Code:
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
|
public static XmlDocument GetXmlDocument()
{
// Create an XmlDocument object.
XmlDocument xmlDocumentObject = new XmlDocument();
xmlDocumentObject.LoadXml("<book genre=\"novel\" publicationdate=\"1997\" " +
" ISBN=\"1-861001-57-5\">" +
" <title>Pride And Prejudice</title>" +
" <author>" +
" <first-name>Jane</first-name>" +
" <last-name>Austen</last-name>" +
" </author>" +
" <price>24.95</price>" +
"</book>");
// Return the created XmlDocument object.
return (xmlDocumentObject);
}
static void Main(string[] args)
{
XmlDocument xml = GetXmlDocument();
ServiceReference1.Service1SoapClient rr = new ConsoleApplication1.ServiceReference1.Service1SoapClient();
string gg = rr.GetFirstName(xml);
} |
j'ai une erreur de compilation :
Citation:
Erreur 2 Argument '1'*: impossible de convertir de 'System.Xml.XmlDocument' en 'System.Xml.XmlElement'
Merci infiniment de votre aide.