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

From: Date: Thu, 10 Mar 2011 10:37:52 +0000
Subject: Re: [SOAP] SOAP wsdl:part name="request" element type question
References: 1 2 3  Groups: php.soap 
Request: Send a blank email to php-soap+get-3271@lists.php.net to get a copy of this message
On 9 March 2011 15:56, <Brendan_Crowley@dellteam.com> wrote: > Hi Richard, > > Thanks for your reply, my files are now up on pastebin: > > ProblemReportService.wsdl:      http://pastebin.com/m9q5tDaN > ProblemReport.xsd:             >  http://pastebin.com/01YPU6Dn > dropdownvalues.xsd:             > http://pastebin.com/1Kvbvf5U > > I've used the wsdl2php.php from > http://pastebin.com/r1BfRysT to create this php file: > ProblemReportService.php:       http://pastebin.com/Txyc1mQM > > I understand that this ProblemReportService.php file needs to be utilised both by SoapClient > and SoapServer, but how can I use this ProblemReportService.php file to handle the contents of my > ProblemReport.xml to create the $request object for the Client? > > Cheers, > Brendan > > -----Original Message----- > From: Richard Quadling [mailto:rquadling@gmail.com] > Sent: 09 March 2011 11:22 > To: Crowley, Brendan - Dell Team > Cc: soap@lists.php.net > Subject: Re: [SOAP] 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="ÝÔ >> ?0Š¥4ʪîr¿­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. > > -- > Richard Quadling > Twitter : EE : Zend > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY > Oh. Interesting. It seems that wsdl2php doesn't support the translation of restricted types to anything concrete. So, currently wsdl2php is only giving you half the story. I don't think there is an instant fix here. I've not had to use a restriction on any of my code or in any of the services I've interacted with. How soon do you need this working? I have an idea on what to do to get wsdl2php working for restrictions, but I'm not able to do anything on it today. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

« previous php.soap (#3271) next »