NuSOAP and manipulating arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jwsolve
Forum Newbie
Posts: 2
Joined: Wed Aug 16, 2006 1:00 pm
Location: United Kingdom

NuSOAP and manipulating arrays

Post by jwsolve »

I have a problem which I need to resolve one way or another, I've trawled the net trying out various ideas and none of them appear to work, then I came across this forum. You may just save my life.

I have been given a WSDL which describes a service relating to a JADE programmed database admin facility for franchises and classes for children. I can connect to the service using php and at the moment I'm just trying to display the output on the screen. However, every time I assign the $client->call('myservice','$params) to a variable it doesn't output anything to the screen. But if I echo $client->response I get what I expect to get. My code is as follows:-

Code: Select all

<?php
require_once('lib/nusoap.php');

$logincheck=array( 'pPassword' => 'fred', 'pStartTime' => '01/01/2006 00:01:00' ); 
$client = new soapclient("my wsdl descriptor");

$login =  $client->call('getChangedFranchises', $logincheck);

$hallcheck = array( 'pPassword' => 'fred', 'pStartTime' => '', 'pSystemId' => '1' ); 
$result = $client->call('getChangedHalls', $hallcheck);

//echo $client->request . "<br />";
//echo $client->response . "<br />";

if ($result['faultstring']) {
	echo '<h2>Error</h2>';
	echo $result['faultstring'];
} else {
	if (is_array($result['resultElements'])) {
		foreach ($result['resultElements'] as $r) {
			print_r($r);
		}
	}
} 
?>
$login is purely to get back a systemId which I can then pass back to $hallcheck params.

echoing the results outputs nothing as well, where am I going wrong as I can see that soap is getting a response and it is the data that I require. I need to be able to cycle through the data and do something useful with it. I appreciate any help I can get as I'm starting to lose my mind.

Thanks

JW
jwsolve
Forum Newbie
Posts: 2
Joined: Wed Aug 16, 2006 1:00 pm
Location: United Kingdom

Post by jwsolve »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


What about if I use PEAR and SOAP, which I'm now trying.

This is the result of a return on the proxy using PEAR and SOAP, don't know whether that helps

Code: Select all

class WebService_AdminProgWebServices_AdminProgWebServicesSoap extends SOAP_Client { 

	function WebService_AdminProgWebServices_AdminProgWebServicesSoap($path = 'path to services') { 
		$this->SOAP_Client($path, 0); 
	} 
	
	function &getChangedFranchises($getChangedFranchises) { 
		// getChangedFranchises is a ComplexType, refer to the WSDL for more info. 
		$getChangedFranchises_attr['xmlns'] = 'urn:JadeWebServices/AdminProgWSInterface/'; 
		$getChangedFranchises =& new SOAP_Value('getChangedFranchises', false, $getChangedFranchises, $getChangedFranchises_attr); 
		$result = $this->call('getChangedFranchises', $v = array('getChangedFranchises' => $getChangedFranchises), array('namespace' => 		'urn:JadeWebServices/AdminProgWSInterface/', 'soapaction' => 'urn:JadeWebServices/AdminProgWSInterface/getChangedFranchises', 'style' => 'document', 'use' => 'literal')); 
		return $result; 
	} 
	
	function &getChangedAreas($getChangedAreas) { // getChangedAreas is a ComplexType, refer to the WSDL for more info.
		$getChangedAreas_attr['xmlns'] = 'urn:JadeWebServices/AdminProgWSInterface/'; 
		$getChangedAreas =& new SOAP_Value('getChangedAreas', false, $getChangedAreas, $getChangedAreas_attr); 
		$result = $this->call('getChangedAreas', $v = array('getChangedAreas' => $getChangedAreas), array('namespace' => 'urn:JadeWebServices/AdminProgWSInterface/', 'soapaction' => 'urn:JadeWebServices/AdminProgWSInterface/getChangedAreas', 'style' => 'document', 'use' => 'literal')); 
		return $result; 
	}
	
	function &getChangedHalls($getChangedHalls) { // getChangedHalls is a ComplexType, refer to the WSDL for more info. 
		$getChangedHalls_attr['xmlns'] = 'urn:JadeWebServices/AdminProgWSInterface/'; 
		$getChangedHalls =& new SOAP_Value('getChangedHalls', false, $getChangedHalls, $getChangedHalls_attr); 
		$result = $this->call('getChangedHalls', $v = array('getChangedHalls' => $getChangedHalls), array('namespace' => 'urn:JadeWebServices/AdminProgWSInterface/', 'soapaction' => 'urn:JadeWebServices/AdminProgWSInterface/getChangedHalls', 'style' => 'document', 'use' => 'literal'));
		return $result; 
	}
	
	function &getChangedClassLevels($getChangedClassLevels) { // getChangedClassLevels is a ComplexType, refer to the WSDL for more info.
		$getChangedClassLevels_attr['xmlns'] = 'urn:JadeWebServices/AdminProgWSInterface/'; 
		$getChangedClassLevels =& new SOAP_Value('getChangedClassLevels', false, $getChangedClassLevels, $getChangedClassLevels_attr); $result = $this->call('getChangedClassLevels', $v = array('getChangedClassLevels' => $getChangedClassLevels), array('namespace' => 'urn:JadeWebServices/AdminProgWSInterface/', 'soapaction' => 'urn:JadeWebServices/AdminProgWSInterface/getChangedClassLevels', 'style' => 'document', 'use' => 'literal')); 
		return $result; 
	} 
	
	function &getChangedClasses($getChangedClasses) { // getChangedClasses is a ComplexType, refer to the WSDL for more info. 
		$getChangedClasses_attr['xmlns'] = 'urn:JadeWebServices/AdminProgWSInterface/'; $getChangedClasses =& new SOAP_Value('getChangedClasses', false, $getChangedClasses, $getChangedClasses_attr); 
		$result = $this->call('getChangedClasses', $v = array('getChangedClasses' => $getChangedClasses), array('namespace' => 'urn:JadeWebServices/AdminProgWSInterface/', 'soapaction' => 'urn:JadeWebServices/AdminProgWSInterface/getChangedClasses', 'style' => 'document', 'use' => 'literal')); 
		return $result; 
	}
}
I've seen the same code that I use but for someone like amazon return an array of results which you can then cycle through and manipulate accordingly, so how come it doesn't seem to work for me. This is the WSDL file, I've had to take out where this is actually located for security reasons.

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:tns="urn:JadeWebServices/AdminProgWSInterface/"
	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   targetNamespace="urn:JadeWebServices/AdminProgWSInterface/"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
>
	<types>
		<xsd:schema elementFormDefault="qualified" targetNamespace="urn:JadeWebServices/AdminProgWSInterface/">
			<xsd:element name="getChangedFranchises">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="pPassword" type="xsd:string" />
						<xsd:element name="pStartTime" type="xsd:dateTime" />
					</xsd:sequence>

				</xsd:complexType>
			</xsd:element>
			<xsd:element name="getChangedFranchisesResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="getChangedFranchisesResult" type="xsd:int" />
						<xsd:element name="pFranchises" type="tns:ArrayOfRTSystem" nillable="true"/>
					</xsd:sequence>
				</xsd:complexType>

			</xsd:element>
			<xsd:element name="getChangedAreas">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="pPassword" type="xsd:string" />
						<xsd:element name="pStartTime" type="xsd:dateTime" />
						<xsd:element name="pSystemId" type="xsd:int" />
					</xsd:sequence>
				</xsd:complexType>

			</xsd:element>
			<xsd:element name="getChangedAreasResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="getChangedAreasResult" type="xsd:int" />
						<xsd:element name="pAreas" type="tns:ArrayOfRTArea" nillable="true"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:element name="getChangedHalls">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="pPassword" type="xsd:string" />
						<xsd:element name="pStartTime" type="xsd:dateTime" />
						<xsd:element name="pSystemId" type="xsd:int" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:element name="getChangedHallsResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="getChangedHallsResult" type="xsd:int" />
						<xsd:element name="pHalls" type="tns:ArrayOfRTHall" nillable="true"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="getChangedClassLevels">

				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="pPassword" type="xsd:string" />
						<xsd:element name="pStartTime" type="xsd:dateTime" />
						<xsd:element name="pSystemId" type="xsd:int" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="getChangedClassLevelsResponse">

				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="getChangedClassLevelsResult" type="xsd:int" />
						<xsd:element name="pClassLevels" type="tns:ArrayOfRTClassLevel" nillable="true"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="getChangedClasses">
				<xsd:complexType>

					<xsd:sequence>
						<xsd:element name="pPassword" type="xsd:string" />
						<xsd:element name="pStartTime" type="xsd:dateTime" />
						<xsd:element name="pSystemId" type="xsd:int" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="getChangedClassesResponse">
				<xsd:complexType>

					<xsd:sequence>
						<xsd:element name="getChangedClassesResult" type="xsd:int" />
						<xsd:element name="pClasses" type="tns:ArrayOfRTClass" nillable="true"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:complexType name="ArrayOfRTSystem">
				<xsd:sequence>
					<xsd:element minOccurs="0" maxOccurs="unbounded" name="RTSystem" type="tns:RTSystem" />

				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="Object" abstract="true">
				<xsd:sequence>
				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="RTSystem">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:RTBaseModel">

						<xsd:sequence>
							<xsd:element name="franchiseeName" type="xsd:string"/>
							<xsd:element name="micrositeURL" type="xsd:string"/>
							<xsd:element name="name" type="xsd:string"/>
							<xsd:element name="systemId" type="xsd:int" minOccurs="0"/>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>

			<xsd:complexType name="RTBaseModel" abstract="true">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:BaseObject">
						<xsd:sequence>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="BaseObject" abstract="true">

				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:Object">
						<xsd:sequence>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="ArrayOfRTArea">
				<xsd:sequence>

					<xsd:element minOccurs="0" maxOccurs="unbounded" name="RTArea" type="tns:RTArea" />
				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="RTArea">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:RTBaseModel">
						<xsd:sequence>
							<xsd:element name="areaId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="name" type="xsd:string"/>

							<xsd:element name="systemId" type="xsd:int" minOccurs="0"/>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="ArrayOfRTHall">
				<xsd:sequence>
					<xsd:element minOccurs="0" maxOccurs="unbounded" name="RTHall" type="tns:RTHall" />
				</xsd:sequence>

			</xsd:complexType>
			<xsd:complexType name="RTHall">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:RTBaseModel">
						<xsd:sequence>
							<xsd:element name="address" type="xsd:string"/>
							<xsd:element name="areaId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="hallId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="name" type="xsd:string"/>

							<xsd:element name="postCode" type="xsd:string"/>
							<xsd:element name="systemId" type="xsd:int" minOccurs="0"/>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="ArrayOfRTClassLevel">
				<xsd:sequence>
					<xsd:element minOccurs="0" maxOccurs="unbounded" name="RTClassLevel" type="tns:RTClassLevel" />

				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="RTClassLevel">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:RTBaseModel">
						<xsd:sequence>
							<xsd:element name="levelId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="lowerAgeLimit" type="xsd:int" minOccurs="0"/>
							<xsd:element name="name" type="xsd:string"/>

							<xsd:element name="systemId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="upperAgeLimit" type="xsd:int" minOccurs="0"/>
						</xsd:sequence>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="ArrayOfRTClass">
				<xsd:sequence>
					<xsd:element minOccurs="0" maxOccurs="unbounded" name="RTClass" type="tns:RTClass" />

				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="RTClass">
				<xsd:complexContent mixed="true">
					<xsd:extension base="tns:RTBaseModel">
						<xsd:sequence>
							<xsd:element name="classId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="cost" type="tns:decimal_6_2" minOccurs="0"/>
							<xsd:element name="day" type="xsd:string"/>

							<xsd:element name="endDate" type="xsd:date" minOccurs="0"/>
							<xsd:element name="hallId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="levelId" type="xsd:int" minOccurs="0"/>
							<xsd:element name="maxInClass" type="xsd:int" minOccurs="0"/>
							<xsd:element name="numberInClass" type="xsd:int" minOccurs="0"/>
							<xsd:element name="startDate" type="xsd:date" minOccurs="0"/>
							<xsd:element name="startTime" type="xsd:time" minOccurs="0"/>
							<xsd:element name="systemId" type="xsd:int" minOccurs="0"/>
						</xsd:sequence>

					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:simpleType name="decimal_6_2">
				<xsd:restriction base="xsd:decimal">
					<xsd:totalDigits value="6"/>
					<xsd:fractionDigits value="2"/>
				</xsd:restriction>
			</xsd:simpleType>

		</xsd:schema>
	</types>
	<message name="getChangedFranchisesSoapIn">
		<part name="inputParameters" element="tns:getChangedFranchises"/>
	</message>
	<message name="getChangedFranchisesSoapOut">
		<part name="return" element="tns:getChangedFranchisesResponse"/>
	</message>
	<message name="getChangedAreasSoapIn">

		<part name="inputParameters" element="tns:getChangedAreas"/>
	</message>
	<message name="getChangedAreasSoapOut">
		<part name="return" element="tns:getChangedAreasResponse"/>
	</message>
	<message name="getChangedHallsSoapIn">
		<part name="inputParameters" element="tns:getChangedHalls"/>
	</message>
	<message name="getChangedHallsSoapOut">

		<part name="return" element="tns:getChangedHallsResponse"/>
	</message>
	<message name="getChangedClassLevelsSoapIn">
		<part name="inputParameters" element="tns:getChangedClassLevels"/>
	</message>
	<message name="getChangedClassLevelsSoapOut">
		<part name="return" element="tns:getChangedClassLevelsResponse"/>
	</message>
	<message name="getChangedClassesSoapIn">

		<part name="inputParameters" element="tns:getChangedClasses"/>
	</message>
	<message name="getChangedClassesSoapOut">
		<part name="return" element="tns:getChangedClassesResponse"/>
	</message>
	<portType name="AdminProgWebServicesSoap">
		<operation name="getChangedFranchises">
			<input message="tns:getChangedFranchisesSoapIn" />
			<output message="tns:getChangedFranchisesSoapOut" />

		</operation>
		<operation name="getChangedAreas">
			<input message="tns:getChangedAreasSoapIn" />
			<output message="tns:getChangedAreasSoapOut" />
		</operation>
		<operation name="getChangedHalls">
			<input message="tns:getChangedHallsSoapIn" />
			<output message="tns:getChangedHallsSoapOut" />
		</operation>

		<operation name="getChangedClassLevels">
			<input message="tns:getChangedClassLevelsSoapIn" />
			<output message="tns:getChangedClassLevelsSoapOut" />
		</operation>
		<operation name="getChangedClasses">
			<input message="tns:getChangedClassesSoapIn" />
			<output message="tns:getChangedClassesSoapOut" />
		</operation>
	</portType>

	<binding name="AdminProgWebServicesSoap" type="tns:AdminProgWebServicesSoap">
		<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
		<operation name="getChangedFranchises">
			<soap:operation soapAction="urn:JadeWebServices/AdminProgWSInterface/getChangedFranchises" style="document"/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />

			</output>
		</operation>
		<operation name="getChangedAreas">
			<soap:operation soapAction="urn:JadeWebServices/AdminProgWSInterface/getChangedAreas" style="document"/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />

			</output>
		</operation>
		<operation name="getChangedHalls">
			<soap:operation soapAction="urn:JadeWebServices/AdminProgWSInterface/getChangedHalls" style="document"/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />

			</output>
		</operation>
		<operation name="getChangedClassLevels">
			<soap:operation soapAction="urn:JadeWebServices/AdminProgWSInterface/getChangedClassLevels" style="document"/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />

			</output>
		</operation>
		<operation name="getChangedClasses">
			<soap:operation soapAction="urn:JadeWebServices/AdminProgWSInterface/getChangedClasses" style="document"/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />

			</output>
		</operation>
	</binding>
	<service name="AdminProgWebServices">
			<port name="AdminProgWebServicesSoap" binding="tns:AdminProgWebServicesSoap">
				<soap:address location="soap url of services" />
			</port>
	</service>
</definitions>
Any help is appreciated and is this enough information to give a good overview?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply