开发者

How do I post XML?

开发者 https://www.devze.com 2023-01-21 14:17 出处:网络
How do I post a XML and get the response status from the response? I want to post <myExampleRequest><myVa开发者_Go百科lue>xyz</myValue></myExampleRequest>

How do I post a XML and get the response status from the response?

I want to post

<myExampleRequest><myVa开发者_Go百科lue>xyz</myValue></myExampleRequest>

to http://domain.com/GetStatus.aspx

The page responds with

<myExampleResponse><status>True</status><Message></Message></myExampleResponse>


It's best not to do too much of this yourself. Use an HTTP Client library like HttpClient or libcurl. Some examples of HttpClient that might help you get started are here.

O'Reilly's HTTP: The Definitive Guide is great for background. I also like RESTful Web Services (which has examples written in libcurl).


You would need to set your Content-type header to text/xml, then echo out your response:

header("Content-type: text/xml");
echo $xml_response;

Use file_get_contents or cURL to process the response into a string, and use some sort of XML parser like SimpleXML to parse the response to get <status>.

0

精彩评论

暂无评论...
验证码 换一张
取 消