0

I used SOAP UI to test my implementation and it works there. However, I do not know how to do this without SOAP UI in a php environment.

I currently have php code pulling data from the MySQL database and outputting well-formed XML, but I do not know how to send this XML output to the web service to be processed.

Any help would be great.

Thanks

rawrzors
  • 167
  • 1
  • 5
  • 13
  • If you want to send the Soap envelope XML directly, you can just to a cURL post request, and set the raw post data to your XML. – MrCode Nov 14 '12 at 16:12

1 Answers1

2

You don't have to create your own SOAP XML. There is a perfectly fine SOAP extension available, where you can create a SoapClient using the services WSDL-file.

http://ch1.php.net/soap

If it is really only about sending the data, use curl.

Configuration example: How can I send SOAP XML via Curl and PHP?

Community
  • 1
  • 1
Louis Huppenbauer
  • 3,719
  • 1
  • 18
  • 24
  • Is it bad practice to skip the WSDL? I already have the code to create the XML and it works perfectly through SOAP UI. On another note, would I use something like $xml = new SoapVar($xml_string, XSD_ANYXML); with $xml_string being the XML code that I output? – rawrzors Nov 14 '12 at 16:11
  • I don't think that it's bad. You're just gonna have to adapt your code when the services changes (new method, new parameters, etc.). When using the wsdl you would only have to use the new functionality but don't actually have to change the xml to generate. If it is really only about sending the data, use [curl](http://ch1.php.net/curl). Configuration example: http://stackoverflow.com/questions/3006977/how-can-i-send-soap-xml-via-curl-and-php – Louis Huppenbauer Nov 14 '12 at 16:14
  • Curl seems pretty interesting. The CURLOPT_POSTFIELDS would be everything between and aside from the security header, which would be in CURLOPT_HTTPHEADER? – rawrzors Nov 14 '12 at 16:21
  • CURLOPT_POSTFIELDS normally contains the HTTP-Request body. The complete xml (probably including ). CURLOPT_HHTPHEADER includes additional http protocol headers (like Content-Type) if needed. I don't exactly know which headers you have to send, so I can't tell you where they belong. – Louis Huppenbauer Nov 14 '12 at 16:23
  • 1
    Alright, thanks. I'll try it soon and let you know how it goes. – rawrzors Nov 14 '12 at 16:25