[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SOAP wsdl:part name="request" element type question

On 9 March 2011 10:53,  <Brendan_Crowley@dellteam.com> wrote:
> I have a WSDL (ProblemReportService.wsdl) that is defined as follows:
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"; xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:tns="http://localhost/ProblemReportService.wsdl"; xmlns:ha1="http://localhost/ProblemReport.xsd"; name="ProblemReportService" targetNamespace="http://localhost/ProblemReportService.wsdl";>
> <wsdl:types>
> Â Â Â Â Â Â<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:ha1="http://localhost/ProblemReport.xsd"; xmlns:xs="http://www.w3.org/2001/XMLSchema";>
> Â Â Â Â Â Â Â Â Â<xs:import namespace="http://localhost/ProblemReport.xsd"; schemaLocation="ProblemReport.xsd"/>
> Â Â Â Â Â Â Â Â Â<xs:import namespace="http://localhost/dropdownvalues.xsd"; schemaLocation="dropdownvalues.xsd"/>
> Â Â Â Â Â Â</xs:schema>
> Â Â Â</wsdl:types>
> <wsdl:message name="NewProblemReportRequest">
> Â Â Â Â Â Â<wsdl:part name="request" element="ha1:ProblemReport"/>
> Â Â Â</wsdl:message>
> <wsdl:message name="ProblemReportResponse">
> Â Â Â Â Â Â<wsdl:part name="parameter" type="xs:string"/>
> Â Â Â</wsdl:message>
> <wsdl:portType name="ProblemReportPortType">
> Â Â Â Â Â Â<wsdl:operation name="submitProblemReport">
> Â Â Â Â Â Â Â Â Â<wsdl:input message="tns:NewProblemReportRequest"/>
> Â Â Â Â Â Â Â Â Â<wsdl:output message="tns:ProblemReportResponse"/>
> Â Â Â Â Â Â</wsdl:operation>
> Â Â Â</wsdl:portType>
> ..
> I've created an xml file (ProblemReport.xml) that validates to ProblemReport.xsd.
> I now have a SOAP Client php file that needs to send this request to the SOAP Server, how would I write the client and server side in php?
> Client:
> try {
> Â Â Â$client = new SoapClient("ProblemReportService.wsdl", array('soap_version' => SOAP_1_1,'trace' => 1 ));
> Â Â Â// How would I define $request from the contents of ProblemReport.xml file?
> Â Â Â$return = $client->__soapCall("submitProblemReport", $request);
> } catch (SoapFault $fault) {
> Â Â Âtrigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
> }
> Server:
> ini_set("soap.wsdl_cache_enabled", "0");
> $server = new SoapServer("http://localhost/ProblemReportService.wsdl";, array('soap_version' => SOAP_1_1));
> $server->addFunction("submitProblemReport");
> $server->handle();
> function submitProblemReport($problem) {
> Â Â Â// How can I validate the $problem against a XSD schema?
> Â Â Â// and how can I unmarshal the $problem to access the data contained within the original xml file?
> }
> Any assistance appreciated.
> Thanks,
> Brendan

Do you have the complete wsdl file?

My solution for the client is always the same.

Wrap the WSDL and SOAPClient into an easy to use set of classes,
essentially hiding the XML and SOAP aspects away and providing a
normal OOP front end.

I use Sourceforge's wsdl2php for that (combined with RazorsEdgeUK's patches).

Take a look through the last few posts I've made on
http://news.php.net/php.soap to see the sort of thing I'm talking
about. There are links to some pastebin code too so you can see the
code I'm creating/using as well as the output being generated.

The SOAPServer's I've created have always been via Zend Framework
which simplifies the creation of the WSDL file - I write the PHP code
I want to expose, I add appropriate DocBlocks to that code and then I
use ZF's AutoDiscover to create the WSDL file.

Then I use wsdl2php to create client classes.

I never write the WSDL file or create XML files or make HTTP requests.

I use OOP and DocBlock documentation.

But with the full wsdl file it should be a relatively simple process
to construct the server classes.

Of course, you _can_ do all of this without any of the
ideas/suggestions I've made. But, for me, that seems to be missing out
on the simplicity that comes with using PHP's SOAPClient and wsdl2php.

Let me know what you need.


Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux