Pico Apico
Pico Apico

Reputation: 21

PHP class generator for web services

I am trying to find some kind of php class generator for Web Services (WCF service if that matters) without any luck so far. Any ideas?

thanks

Upvotes: 2

Views: 2408

Answers (2)

Henrik Opel
Henrik Opel

Reputation: 19441

According to this Question & Answer, you can use the generateProxyCode() method of the PEAR SOAP_WSDL class.

Upvotes: 1

Ivan Krechetov
Ivan Krechetov

Reputation: 19220

I'd say there's a dubious benefit from static generation of the classes wrapping a SOAP service in a dynamic language like PHP. What I usually do is just hand-crafting the SOAP HTTP request and then feeding the results to SimpleXMLElement, like:

$Response = new SimpleXMLElement($soap_response_xml);
echo strval($Response->ElementA->ElementB['AttributeC']);

Which corresponds to SOAP response XML:

<Response>
    <ElementA>
        <ElementB AttributeC="foo"/>
    </ElementA>
</Response>

and outputs "foo".

This way has no WSDL parsing overhead. But if you do want to deal with WSDL, and avoid hand-crafting the HTTP request, check this out.

In either way, it's better to "generate the classes" at runtime, because your language allows that.

Upvotes: 0

Related Questions