Welcome Guest, Not a member yet? Register   Sign In
How to POST XML data in codeigniter?
#1

[eluser]wahyusumartha[/eluser]
hello..
i have a problem while posting xml data to a url .....
could someone give me an example how to posting xml????
#2

[eluser]Udi[/eluser]
Why you need to post XML data with URL??
What are you trying to do?
#3

[eluser]wahyusumartha[/eluser]
i want to develop web service client with codeigniter.. so i have to post data with xml format...

for example :
i want to post this xml :
<customer>
<firstname>wahyu</firstname>
<lastname>sumartha</lastname>
</customer>

xml data above would be post to url (http://example.com:9090/resource/customer/add)

could u help me how to do it ???
#4

[eluser]Udi[/eluser]
You can't post XML data to url,
URL grabs XML data or prints it.

Is there any way that [http://example.com:9090/resource/customer/add] will grab the given XML?
#5

[eluser]wahyusumartha[/eluser]
Really ????
this url[http://example.com:9090/resource/customer/add] consumes xml data..
so, i have to post xml ...
i think we can post xml data.. because i have been developing desktop application with that web service and worked properly
#6

[eluser]Udi[/eluser]
Maybe you send it with regular POST and Form and then it builds the XML by itself.
#7

[eluser]wahyusumartha[/eluser]
i have been solved the problem with using curl to post xml data
Thanks Wink
#8

[eluser]Udi[/eluser]
You mind sharing the code?
I'm trying to understand what you did and meant exactly.
#9

[eluser]wahyusumartha[/eluser]
okay.. i will share the code Smile..
i want to post xml to web service server..

so i write controller like this :

function add_customer() {

$post = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n\n";
$post .= "<customer>\n";
$post .= "<firstname>sinichi</firstname>\n";
$post .= "<lastname>kudo</lastname>\n";
$post .= "</customer>\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"http://localhost:9090/TestRestful/resources/customersservice/add");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$res = curl_exec($ch);
curl_close ($ch);
echo $res;
}

controller above have a function to post xml data to web service server using curl Smile..
are you understand my problem previously now ? Smile




Theme © iAndrew 2016 - Forum software by © MyBB