Replies: 4 comments
-
Hey, yes you can use Saloon to integrate with XML/Soap-based APIs but traditionally where you might use a SOAP client to build up the XML, with Saloon you would have to build up the XML manually. In the past, I've used Spatie's Array to XML library which is excellent as you can build up a simple XML body with PHP arrays. Saloon has some documentation around using XML with this library. https://github.com/spatie/array-to-xml Please let me know if you try it and have any suggestions to improve this. To send XML you would do something like this... class MakeCarRequest extends Request implements HasBody
{
use HasXmlBody; // This will set the Content-Type but add the `body` method so you can set the XML
// ... Method, endpoint etc
}
//
$connector = new XMLConnector;
$request = new MakeCarRequest;
// When using the HasXMLBody trait, the `set` method will expect a string of raw XML
$request->body()->set(
ArrayToXml::convert($array)
); |
Beta Was this translation helpful? Give feedback.
-
I'd like to contribute to this. I have a use case where I need to call a SOAP service and i'd like to use Saloon so I can maintain my already-in-use REST structure. I'll make a PR when I have some time. |
Beta Was this translation helpful? Give feedback.
-
currently, been fleshing out the project, and later been planning to create API rest and, API with soap :), but these things take time as we know. |
Beta Was this translation helpful? Give feedback.
-
Hey @scajal I'd be interested to know what you were thinking of with your PR! Any detail you can give here? :) |
Beta Was this translation helpful? Give feedback.
-
Hi, can it be used with soap ?
Beta Was this translation helpful? Give feedback.
All reactions