on 10-23-2013 10:55 AM
Hi Group,
I am trying to send an XML from my localhost to SAP MII server using the HTTP post.
I made a processing rule of transaction type and linked a transaction that has XML as input and string as output.
I made sure that the Message name is same as what I send in the URL.
But i get the following error:
Invalid XML in the payLoad; XML is not well formed
I am sending the code that I wrote. Please help me understand where I went wrong, as I have gone through all the forums about this and got the code etc from those forums only.
Please help, as this is an urgent requirement.
The code I am using is a php code:
<?php
//paste your XML file here
$xml = '
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE>
<shiporder>
<orderID>1234</orderID>
<orderperson>John Smith</orderperson>
</shiporder>';
$headers = array(
"Content-type: text/xml",
"Content-length: " . strlen($xml),
"Connection: close",
);
// give the path of the Third party site
$url = "http://<server>:<host>/XMII/Illuminator?service=WSMessageListener&mode=WSMessageListenerServer&NAME=shiporder&IllumLoginName=<name>&IllumLoginPassword=<pswd>";
echo $xml;
echo $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
Regards,
Gita
Hi Gita,
Are you sure there is no space when the XML is formed? when I use your XML ,
$xml= "
<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<!DOCTYPE>
<shiporder>
<orderID>1234</orderID>
<orderperson>John Smith</orderperson>
</shiporder>";
echo '<pre>', htmlentities($xml), '</pre>';
the output gave me an XML with a space in front of it. This could be because of an extra line in the xml declaration.
Regards
Tufale Ashai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gita,
Your xml is incorrect. Try pasting it in a notepad, save as abc.xml and run in a browser. You will see that it doesn't render in browser.
The reason is the <!DOCTYPE> tag in the xml! This is an HTML tag and is not valid in an xml.
Remove that and I guess your problem will be solved
Thanks,
Rutika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rutika,
I would like to clear here that <!DOCTYPE> is a declaration (known as DTD) and can be used in XML as well. But for an XML, addition of the root element is a part of this declaration which is not there in the XML pasted by Gita, so if you correct that as I have mentioned in my earlier post, then also you can see the XML in your browser. Well, removing it will anyways solve the issue 🙂
Thanks & Regards,
Anuj
Hi Gita,
The error you are getting suggests that something is wrong with your XML structure.
As I can see, the DTD in your XML seems to be incorrect as it should be in the below format
<!DOCTYPE rootElementName>
so, in your case, it should be <!DOCTYPE shiporder>
Give it a try, hope it resolves your issue.
Best Regards,
Anuj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anuj,
I tried doing that, but no change.
Have you done this before in 14.0 without any issues? is it necessary to mention a Schema, XPath for Message Name, XPath for Message UID in the configurations tab of Message Listeners?
I tried with and without it, does not help.
Experts please help.
Regards,
Gita
User | Count |
---|---|
11 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.