0

One of my customers recently asked me to integrate his webservice with some external companies API. I have to add integration controller in PHP as this is how his form is being processed.

The company provided me with:

1) WSDL definition of web service,

2) An example named contract.xml,

3) Two .xsd files that are to be used to data validation,

4) Three .xml examples (of soap request, response-true and response-false)

I've never done anything like this and i'm wondering if there's any point trying, would be very grateful if anyone could provide me with some knowledge that would let me start thinking my own way on this subject.

What would be the schema like: setting 'blank' request as PHP var and updating it with forms input would be good solution? Or should i rather try to learn some more on XML parsing and go this way?

1 Answer 1

2

you don't need to parse any xml, if you have WSDL (web service documentation language) xml file or you have online access to the wsdl of the service with which you going to comunicate, all that you should do define the object

$mySoapClient = new SoapClient("path/to/your/wsdl.xml", array("here you should write the params that required your soap service"));

also there might be user credential which you can set with

$soapClient = new SoapClient("https://soapserver.example.com/blahblah.asmx?wsdl"); 

// Prepare SoapHeader parameters 
$sh_param = array( 
            'Username'    =>    'username', 
            'Password'    =>    'password'); 
$headers = new SoapHeader('http://soapserver.example.com/webservices', 'UserCredentials', $sh_param); 

// Prepare Soap Client 
$soapClient->__setSoapHeaders(array($headers)); 

after connection you will use your $soapClient object to get access to all methods that provide your soap server like this

$soapClient->someMethodThatProvideMySoapServer($someParams);

this method someMethodThatProvideMySoapServer you don't have in your server this coming from soap server and you can use it for more detailes you can learn from here http://php.net/manual/en/book.soap.php http://php.net/manual/en/class.soapclient.php Creating a SOAP call using PHP with an XML body

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Armen for contribution, will give it a look in few hours but seems like this is exactly what I was looking for, once i make sure it works fine i'll accept the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.