Reputation: 59
I have form in PHP, and I should generate some data from form and send it to c# web service. What is the best way to call my c# web service method from PHP web site? This is my C# web service
public string Methode1(string Par1, int Par2, List<String> par3)
My list Par3 should contain few thousand elements. Should I use JSON or should I make an array in PHP and send it to C# via SOAP call? How should I create request?
What if connection drops, what will happen to request in JSON or in SOAP?
Upvotes: 1
Views: 1673
Reputation: 3493
I recently used PHP to call a C# ServiceStack service. it goes like this:
$content = json_encode($yourServiceMethodsArgumentShapeInstance);
$curl = curl_init($endpointUrl);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$jsonResponse = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
Upvotes: 1
Reputation: 116140
The same will happen to either. A request is just an HTTP request. The contents of the response contains either a SOAP message or any other content, which may be JSON. If you receive a half message, you probably cannot parse it, regardless whether it contains JSON or a SOAP XML message.
Personally I'm not a big fan of SOAP and would rather choose a REST interface, based on JSON.
Upvotes: 2