SOAP wsdl:part name="request" element type question
[email protected] Wed, 9 Mar 2011 10:53:15 +0000
| Newsgroups | php.soap |
|---|---|
| Message-ID | <02C93ED8E0C15B49B599E3BE866EED8A0BE0FBD9@EMAX10HMNDC01.EMEA.DELL.COM> |
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