Hi, I have a wsdl I have to conform to that looks like this:
At the moment I can get my input to pass the wsdl, but I can't seem to pass a response back.
My server code looks like this:
My client like this:
The output I see shows the request xml gets generated correctly, but the response xml just has a closing tag for the output parameters and the php debugger shows
ie. the result appears to be an empty object of stdClass.
The output is as follows:
I cannot figure out how to build the response as a nested array that matches the wsdl. Can anyone help?
Code:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://www.paaleads.com/LeadConsumerService/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.paaleads.com/LeadConsumerService/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.paaleads.com/LeadConsumerService/">
<s:element name="ConsumeLead">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="request" type="tns:ConsumeLeadRequest" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ConsumeLeadRequest">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="LeadType" type="tns:LeadType" />
<s:element minOccurs="0" maxOccurs="1" name="LeadXml" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="AuthenticationUsername" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="AuthenticationPassword" type="s:string" />
</s:sequence>
</s:complexType>
<s:simpleType name="LeadType">
<s:restriction base="s:string">
<s:enumeration value="Unknown" />
<s:enumeration value="Mortgage" />
<s:enumeration value="TermAssurance" />
<s:enumeration value="Travel" />
<s:enumeration value="PMI" />
<s:enumeration value="SecuredLoan" />
<s:enumeration value="CreditHelp" />
<s:enumeration value="Stakeholder" />
<s:enumeration value="TermPostal" />
<s:enumeration value="Pension" />
<s:enumeration value="Savings" />
<s:enumeration value="Investments" />
<s:enumeration value="UnsecuredLoan" />
<s:enumeration value="OverseasMortgage" />
<s:enumeration value="Debt" />
<s:enumeration value="ASU" />
<s:enumeration value="LegalServices" />
</s:restriction>
</s:simpleType>
<s:element name="ConsumeLeadResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ConsumeLeadResult" type="tns:ConsumeLeadResponse" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ConsumeLeadResponse">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="LeadReceived" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="FailureMessage" type="s:string" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="ConsumeLeadSoapIn">
<wsdl:part name="parameters" element="tns:ConsumeLead" />
</wsdl:message>
<wsdl:message name="ConsumeLeadSoapOut">
<wsdl:part name="parameters" element="tns:ConsumeLeadResponse" />
</wsdl:message>
<wsdl:portType name="LeadConsumerServiceSoap">
<wsdl:operation name="ConsumeLead">
<wsdl:input message="tns:ConsumeLeadSoapIn" />
<wsdl:output message="tns:ConsumeLeadSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LeadConsumerServiceSoap" type="tns:LeadConsumerServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ConsumeLead">
<soap:operation soapAction="http://www.paaleads.com/LeadConsumerService/ConsumeLead" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="LeadConsumerServiceSoap12" type="tns:LeadConsumerServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ConsumeLead">
<soap12:operation soapAction="http://www.paaleads.com/LeadConsumerService/ConsumeLead" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LeadConsumerService">
<wsdl:port name="LeadConsumerServiceSoap" binding="tns:LeadConsumerServiceSoap">
<soap:address location="http://localhost:8080/dealdirectfinancial.co.uk/paaleads/PAALeadServer.php" />
</wsdl:port>
<wsdl:port name="LeadConsumerServiceSoap12" binding="tns:LeadConsumerServiceSoap12">
<soap12:address location="http://localhost:8080/dealdirectfinancial.co.uk/paaleads/PAALeadServer.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
My server code looks like this:
Code:
<?php
# PAALeadServer.php
# SiteWeavers Web Solutions (http:www.siteweavers.co.uk)
#
function ConsumeLead($data)
$response =
array(
'ConsumeLeadResponse' =>
array(
'ConsumeLeadResult' =>
array(
'LeadReceived' => 'true'
)
)
);
return $response;
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("http://localhost:8080/dealdirectfinancial.co.uk/paaleads/LeadConsumerService.wsdl");
$server->addFunction("ConsumeLead");
$server->handle();
?>
Code:
<?php
$leadType = 'Mortgage';
$leadXML = '
<ns1:LeadAssigned xmlns:ns1="http://PAA.LeadDelivery.Generic.Schemas.LeadAssigned" xmlns:ns0="http://PAA.LeadDelivery.Generic.Schemas.Lead" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Lead>
<Reference>
1234
</Reference>
<Product>
<Mnemonic>
Mortgage
</Mnemonic>
<Description>
Mortgage Leads
</Description>
<SubType>
Other
</SubType>
</Product>
<ExtendedInfo>
<Mortgage>
<MortgageValue>
75000
</MortgageValue>
<MortgageValueLowerBound>
1
</MortgageValueLowerBound>
<MortgageValueUpperBound>
500
</MortgageValueUpperBound>
<PropertyValue>
100000
</PropertyValue>
<PropertyValueLowerBound>
1
</PropertyValueLowerBound>
<PropertyValueUpperBound>
500
</PropertyValueUpperBound>
<Adverse>
false
</Adverse>
<FirstTime>
false
</FirstTime>
</Mortgage>
</ExtendedInfo>
<Applicants>
<Applicant1>
<Title>
Mr
</Title>
<Forename>
SampleForename
</Forename>
<Surname>
SampleSurname
</Surname>
<DateOfBirth>
1903-02-01
</DateOfBirth>
<Smoker>
false
</Smoker>
<TelephoneNumbers>
<TelephoneNumber>
<Number>
01244123456
</Number>
<Type>
Mobile
</Type>
</TelephoneNumber>
</TelephoneNumbers>
<EmailAddresses>
<EmailAddress>
<Email>
test@moneysupermarket.com
</Email>
<Type>
Business
</Type>
</EmailAddress>
</EmailAddresses>
<Addresses>
<Address>
<Street>
Sample Street
</Street>
<District>
Sample District
</District>
<Town>
Sample Town
</Town>
<County>
Sample County
</County>
<Postcode>
CH53UZ
</Postcode>
<Type>
Home
</Type>
</Address>
</Addresses>
</Applicant1>
</Applicants>
</ns0:Lead>
<Assignment>
<Price>
20
</Price>
<AssignmentDateTime>
2010-02-01T00:00:00
</AssignmentDateTime>
<Subscription>
<Reference>
1234
</Reference>
<Subscriber>
<Title>
Mr
</Title>
<Forename>
SampleForename
</Forename>
<Surname>
SampleSurname
</Surname>
</Subscriber>
</Subscription>
<Account>
<Reference>
1234
</Reference>
<CompanyName>
Sample Company
</CompanyName>
</Account>
<LeadType>
SampleLeadType
</LeadType>
<TerritoryName>
UNITED KINGDOM
</TerritoryName>
</Assignment>
</ns1:LeadAssigned>
';
$server = "http://localhost:8080/dealdirectfinancial.co.uk/paaleads/";
$wsdl = $server . "LeadConsumerService.wsdl";
try {
$client = new SoapClient($wsdl,
array("trace"=>1,"exceptions"=>1));
ob_start();
var_dump($client->__getFunctions());
$dump = ob_get_contents();
ob_end_clean();
printf("<br />Dumping client object functions:<br /><pre>%s</pre>", $dump);
// Create the parameters
$params =
array(
'ConsumeLead' =>
array( 'request' =>
array(
"LeadType" => $leadType,
"LeadXml" => $leadXML,
"AuthenticationUsername" => 'dealdirectfinancial',
"AuthenticationPassword" => 'opensesame'
)
)
);
//$params = array(new SoapParam($params, 'ConsumeLeadRequest'));
// Make the call to the service
#$result = $client->ConsumeLead($params);
$result = $client->__soapCall('ConsumeLead', $params);
// Print the result
printf("Printing the response: <br /><br />");
print_r($result->ConsumeLeadResponse);
} catch (SoapFault $e) {
echo "Error: {$e->faultstring}";
}
// display what was sent to the server (the request)
printf("Request: %s <br />", htmlspecialchars($client->__getLastRequest()));
// display what came back from the server (the response)
printf("Response: %s <br />", htmlspecialchars($client->__getLastResponse()));
?>
Code:
$result: object(stdClass) =
The output is as follows:
Code:
Dumping client object functions:
array(2) {
[0]=>
string(56) "ConsumeLeadResponse ConsumeLead(ConsumeLead $parameters)"
[1]=>
string(56) "ConsumeLeadResponse ConsumeLead(ConsumeLead $parameters)"
}
Printing the response:
Request: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.paaleads.com/LeadConsumerService/"><SOAP-ENV:Body><ns1:ConsumeLead><ns1:request><ns1:LeadType>Mortgage</ns1:LeadType><ns1:LeadXml>
&lt;ns1:LeadAssigned xmlns:ns1="http://PAA.LeadDelivery.Generic.Schemas.LeadAssigned" xmlns:ns0="http://PAA.LeadDelivery.Generic.Schemas.Lead" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;ns0:Lead&gt;
&lt;Reference&gt;
1234
&lt;/Reference&gt;
&lt;Product&gt;
&lt;Mnemonic&gt;
Mortgage
&lt;/Mnemonic&gt;
&lt;Description&gt;
Mortgage Leads
&lt;/Description&gt;
&lt;SubType&gt;
Other
&lt;/SubType&gt;
&lt;/Product&gt;
&lt;ExtendedInfo&gt;
&lt;Mortgage&gt;
&lt;MortgageValue&gt;
75000
&lt;/MortgageValue&gt;
&lt;MortgageValueLowerBound&gt;
1
&lt;/MortgageValueLowerBound&gt;
&lt;MortgageValueUpperBound&gt;
500
&lt;/MortgageValueUpperBound&gt;
&lt;PropertyValue&gt;
100000
&lt;/PropertyValue&gt;
&lt;PropertyValueLowerBound&gt;
1
&lt;/PropertyValueLowerBound&gt;
&lt;PropertyValueUpperBound&gt;
500
&lt;/PropertyValueUpperBound&gt;
&lt;Adverse&gt;
false
&lt;/Adverse&gt;
&lt;FirstTime&gt;
false
&lt;/FirstTime&gt;
&lt;/Mortgage&gt;
&lt;/ExtendedInfo&gt;
&lt;Applicants&gt;
&lt;Applicant1&gt;
&lt;Title&gt;
Mr
&lt;/Title&gt;
&lt;Forename&gt;
SampleForename
&lt;/Forename&gt;
&lt;Surname&gt;
SampleSurname
&lt;/Surname&gt;
&lt;DateOfBirth&gt;
1903-02-01
&lt;/DateOfBirth&gt;
&lt;Smoker&gt;
false
&lt;/Smoker&gt;
&lt;TelephoneNumbers&gt;
&lt;TelephoneNumber&gt;
&lt;Number&gt;
01244123456
&lt;/Number&gt;
&lt;Type&gt;
Mobile
&lt;/Type&gt;
&lt;/TelephoneNumber&gt;
&lt;/TelephoneNumbers&gt;
&lt;EmailAddresses&gt;
&lt;EmailAddress&gt;
&lt;Email&gt;
test@moneysupermarket.com
&lt;/Email&gt;
&lt;Type&gt;
Business
&lt;/Type&gt;
&lt;/EmailAddress&gt;
&lt;/EmailAddresses&gt;
&lt;Addresses&gt;
&lt;Address&gt;
&lt;Street&gt;
Sample Street
&lt;/Street&gt;
&lt;District&gt;
Sample District
&lt;/District&gt;
&lt;Town&gt;
Sample Town
&lt;/Town&gt;
&lt;County&gt;
Sample County
&lt;/County&gt;
&lt;Postcode&gt;
CH53UZ
&lt;/Postcode&gt;
&lt;Type&gt;
Home
&lt;/Type&gt;
&lt;/Address&gt;
&lt;/Addresses&gt;
&lt;/Applicant1&gt;
&lt;/Applicants&gt;
&lt;/ns0:Lead&gt;
&lt;Assignment&gt;
&lt;Price&gt;
20
&lt;/Price&gt;
&lt;AssignmentDateTime&gt;
2010-02-01T00:00:00
&lt;/AssignmentDateTime&gt;
&lt;Subscription&gt;
&lt;Reference&gt;
1234
&lt;/Reference&gt;
&lt;Subscriber&gt;
&lt;Title&gt;
Mr
&lt;/Title&gt;
&lt;Forename&gt;
SampleForename
&lt;/Forename&gt;
&lt;Surname&gt;
SampleSurname
&lt;/Surname&gt;
&lt;/Subscriber&gt;
&lt;/Subscription&gt;
&lt;Account&gt;
&lt;Reference&gt;
1234
&lt;/Reference&gt;
&lt;CompanyName&gt;
Sample Company
&lt;/CompanyName&gt;
&lt;/Account&gt;
&lt;LeadType&gt;
SampleLeadType
&lt;/LeadType&gt;
&lt;TerritoryName&gt;
UNITED KINGDOM
&lt;/TerritoryName&gt;
&lt;/Assignment&gt;
&lt;/ns1:LeadAssigned&gt;
</ns1:LeadXml><ns1:AuthenticationUsername>dealdirectfinancial</ns1:AuthenticationUsername><ns1:AuthenticationPassword>opensesame</ns1:AuthenticationPassword></ns1:request></ns1:ConsumeLead></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.paaleads.com/LeadConsumerService/"><SOAP-ENV:Body><ns1:ConsumeLeadResponse/></SOAP-ENV:Body></SOAP-ENV:Envelope>
Comment