Need help generating a response that matches wsdl

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

 



Hi, I have a wsdl I have to conform to that looks like this:
[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>
[/code]
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:
[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]
My client like this:
[code]
<?php

   $leadType = 'Mortgage';

   $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;
    ';

	$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]
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
[code] $result: object(stdClass) = [/code] ie. the result appears to be an
empty object of 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>&#13;
&amp;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"&amp;gt;&#13;
&amp;lt;ns0:Lead&amp;gt;&#13; &amp;lt;Reference&amp;gt;&#13; 1234&#13;
&amp;lt;/Reference&amp;gt;&#13; &amp;lt;Product&amp;gt;&#13;
&amp;lt;Mnemonic&amp;gt;&#13; Mortgage&#13; &amp;lt;/Mnemonic&amp;gt;&#13;
&amp;lt;Description&amp;gt;&#13; Mortgage Leads&#13;
&amp;lt;/Description&amp;gt;&#13; &amp;lt;SubType&amp;gt;&#13; Other&#13;
&amp;lt;/SubType&amp;gt;&#13; &amp;lt;/Product&amp;gt;&#13;
&amp;lt;ExtendedInfo&amp;gt;&#13; &amp;lt;Mortgage&amp;gt;&#13;
&amp;lt;MortgageValue&amp;gt;&#13; 75000&#13;
&amp;lt;/MortgageValue&amp;gt;&#13;
&amp;lt;MortgageValueLowerBound&amp;gt;&#13; 1&#13;
&amp;lt;/MortgageValueLowerBound&amp;gt;&#13;
&amp;lt;MortgageValueUpperBound&amp;gt;&#13; 500&#13;
&amp;lt;/MortgageValueUpperBound&amp;gt;&#13;
&amp;lt;PropertyValue&amp;gt;&#13; 100000&#13;
&amp;lt;/PropertyValue&amp;gt;&#13;
&amp;lt;PropertyValueLowerBound&amp;gt;&#13; 1&#13;
&amp;lt;/PropertyValueLowerBound&amp;gt;&#13;
&amp;lt;PropertyValueUpperBound&amp;gt;&#13; 500&#13;
&amp;lt;/PropertyValueUpperBound&amp;gt;&#13; &amp;lt;Adverse&amp;gt;&#13;
false&#13; &amp;lt;/Adverse&amp;gt;&#13; &amp;lt;FirstTime&amp;gt;&#13;
false&#13; &amp;lt;/FirstTime&amp;gt;&#13; &amp;lt;/Mortgage&amp;gt;&#13;
&amp;lt;/ExtendedInfo&amp;gt;&#13; &amp;lt;Applicants&amp;gt;&#13;
&amp;lt;Applicant1&amp;gt;&#13; &amp;lt;Title&amp;gt;&#13; Mr&#13;
&amp;lt;/Title&amp;gt;&#13; &amp;lt;Forename&amp;gt;&#13;
SampleForename&#13; &amp;lt;/Forename&amp;gt;&#13;
&amp;lt;Surname&amp;gt;&#13; SampleSurname&#13;
&amp;lt;/Surname&amp;gt;&#13; &amp;lt;DateOfBirth&amp;gt;&#13;
1903-02-01&#13; &amp;lt;/DateOfBirth&amp;gt;&#13;
&amp;lt;Smoker&amp;gt;&#13; false&#13; &amp;lt;/Smoker&amp;gt;&#13;
&amp;lt;TelephoneNumbers&amp;gt;&#13; &amp;lt;TelephoneNumber&amp;gt;&#13;
&amp;lt;Number&amp;gt;&#13; 01244123456&#13; &amp;lt;/Number&amp;gt;&#13;
&amp;lt;Type&amp;gt;&#13; Mobile&#13; &amp;lt;/Type&amp;gt;&#13;
&amp;lt;/TelephoneNumber&amp;gt;&#13; &amp;lt;/TelephoneNumbers&amp;gt;&#13;
&amp;lt;EmailAddresses&amp;gt;&#13; &amp;lt;EmailAddress&amp;gt;&#13;
&amp;lt;Email&amp;gt;&#13; test@moneysupermarket.com&#13;
&amp;lt;/Email&amp;gt;&#13; &amp;lt;Type&amp;gt;&#13; Business&#13;
&amp;lt;/Type&amp;gt;&#13; &amp;lt;/EmailAddress&amp;gt;&#13;
&amp;lt;/EmailAddresses&amp;gt;&#13; &amp;lt;Addresses&amp;gt;&#13;
&amp;lt;Address&amp;gt;&#13; &amp;lt;Street&amp;gt;&#13; Sample Street&#13;
&amp;lt;/Street&amp;gt;&#13; &amp;lt;District&amp;gt;&#13; Sample
District&#13; &amp;lt;/District&amp;gt;&#13; &amp;lt;Town&amp;gt;&#13;
Sample Town&#13; &amp;lt;/Town&amp;gt;&#13; &amp;lt;County&amp;gt;&#13;
Sample County&#13; &amp;lt;/County&amp;gt;&#13;
&amp;lt;Postcode&amp;gt;&#13; CH53UZ&#13; &amp;lt;/Postcode&amp;gt;&#13;
&amp;lt;Type&amp;gt;&#13; Home&#13; &amp;lt;/Type&amp;gt;&#13;
&amp;lt;/Address&amp;gt;&#13; &amp;lt;/Addresses&amp;gt;&#13;
&amp;lt;/Applicant1&amp;gt;&#13; &amp;lt;/Applicants&amp;gt;&#13;
&amp;lt;/ns0:Lead&amp;gt;&#13; &amp;lt;Assignment&amp;gt;&#13;
&amp;lt;Price&amp;gt;&#13; 20&#13; &amp;lt;/Price&amp;gt;&#13;
&amp;lt;AssignmentDateTime&amp;gt;&#13; 2010-02-01T00:00:00&#13;
&amp;lt;/AssignmentDateTime&amp;gt;&#13; &amp;lt;Subscription&amp;gt;&#13;
&amp;lt;Reference&amp;gt;&#13; 1234&#13; &amp;lt;/Reference&amp;gt;&#13;
&amp;lt;Subscriber&amp;gt;&#13; &amp;lt;Title&amp;gt;&#13; Mr&#13;
&amp;lt;/Title&amp;gt;&#13; &amp;lt;Forename&amp;gt;&#13;
SampleForename&#13; &amp;lt;/Forename&amp;gt;&#13;
&amp;lt;Surname&amp;gt;&#13; SampleSurname&#13;
&amp;lt;/Surname&amp;gt;&#13; &amp;lt;/Subscriber&amp;gt;&#13;
&amp;lt;/Subscription&amp;gt;&#13; &amp;lt;Account&amp;gt;&#13;
&amp;lt;Reference&amp;gt;&#13; 1234&#13; &amp;lt;/Reference&amp;gt;&#13;
&amp;lt;CompanyName&amp;gt;&#13; Sample Company&#13;
&amp;lt;/CompanyName&amp;gt;&#13; &amp;lt;/Account&amp;gt;&#13;
&amp;lt;LeadType&amp;gt;&#13; SampleLeadType&#13;
&amp;lt;/LeadType&amp;gt;&#13; &amp;lt;TerritoryName&amp;gt;&#13; UNITED
KINGDOM&#13; &amp;lt;/TerritoryName&amp;gt;&#13;
&amp;lt;/Assignment&amp;gt;&#13; &amp;lt;/ns1:LeadAssigned&amp;gt;&#13;
</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> 
[/code]
I cannot figure out how to build the response as a nested array that matches
the wsdl. Can anyone help?
-- 
View this message in context: http://old.nabble.com/Need-help-generating-a-response-that-matches-wsdl-tp29890878p29890878.html
Sent from the Php - Soap mailing list archive at Nabble.com.


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



[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux