/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] NuSOAP

hi

I’m trying to get a request and response to work using the NuSOAP class. ?

My NuSOAP function is:

[code=php]
<?php
/*
* $Id: client2.php,v 1.4 2007/11/06 14:48:24 snichol Exp $
*
* Client sample.
*
* Service: SOAP endpoint
* Payload: rpc/encoded
* Transport: http
* Authentication: none
*/
require_once(‘../lib/nusoap.php’);
$proxyhost = isset($_POST[‘proxyhost’]) ? $_POST[‘proxyhost’] : ”;
$proxyport = isset($_POST[‘proxyport’]) ? $_POST[‘proxyport’] : ”;
$proxyusername = isset($_POST[‘proxyusername’]) ? $_POST[‘proxyusername’] : ”;
$proxypassword = isset($_POST[‘proxypassword’]) ? $_POST[‘proxypassword’] : ”;
$useCURL = isset($_POST[‘usecurl’]) ? $_POST[‘usecurl’] : ‘0’;
$client = new nusoap_client(“http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer”, false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
echo ‘<h2>Debug</h2><pre>’ . htmlspecialchars($client->getDebug(), ENT_QUOTES) . ‘</pre>’;
exit();
}
$client->setUseCurl($useCURL);
$client->useHTTPPersistentConnection();

//$header .= “<soap:Header><RetailSoapHeader xmls=”http://tempuri.org”><Password>password</Password><Username>username</Username></RetailSoapHeader>”;

$params = array(
‘CenterId’ => date(‘Ymdhis’), // Wigan = 1
‘MemberId’ => date(‘Ymdhis’),
‘CardNumber’ => date(‘Ymdhis’),
‘Title’ => ‘Mr’,
‘ForeName’ => ‘Tim’,
‘Surname’ => ‘Smith’,
‘Sex’ => ‘M’,
‘YearOfBirth’ => ‘1982’,
‘NumberOfChildren’ => ‘0’,
‘EmailAddress’ => ‘**@demo.co.uk’,
‘Mobile’ => date(‘Ymdhis’),
‘PhoneNumber’ => date(‘Ymdhis’),
‘AddressLine1’ => ‘Jordan Street’,
‘AddressLine2’ => ”,
‘HouseName’ => ”,
‘HouseNumber’ => ‘3’,
‘Postcode’ => ‘M15 4PY’,
‘NumberOfPeopleInHouse’ => ‘2’,
‘Password’ => ‘global’,
‘Preference’ => ”,
‘HasDrivingLicence’ => ‘0’,
‘OwnACar’ => ‘0’,
‘NumberOfCarsInHouseHold’ => ‘1’,
‘CarTravelFrequency’ => ‘2’, // 1 = daily, 2 = Weekly, 3 = Monthly, 4 = Yearly, 5 = Never
‘BusTravelFrequency’ => ‘3’, // 1 = daily, 2 = Weekly, 3 = Monthly, 4 = Yearly, 5 = Never
‘TrainTravelFrequency’ => ‘4’, // 1 = daily, 2 = Weekly, 3 = Monthly, 4 = Yearly, 5 = Never
‘PlaneTravelFreqency’ => ‘5’, // 1 = daily, 2 = Weekly, 3 = Monthly, 4 = Yearly, 5 = Never
‘MotorBikeTravelFrequency’ => ‘5’, // 1 = daily, 2 = Weekly, 3 = Monthly, 4 = Yearly, 5 = Never
‘UniqId’ => date(‘Ymdhis’)
);
$result = $client->call(‘RegistrationCustomer’, $params, ‘http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer’, ‘http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer’);
if ($client->fault) {
echo ‘<h2>Fault</h2><pre>’; print_r($result); echo ‘</pre>’;
} else {
$err = $client->getError();
if ($err) {
echo ‘<h2>Error</h2><pre>’ . $err . ‘</pre>’;
} else {
echo ‘<h2>Result</h2><pre>’; print_r($result); echo ‘</pre>’;
}
}
echo ‘<h2>Request</h2><pre>’ . htmlspecialchars($client->request, ENT_QUOTES) . ‘</pre>’;
echo ‘<h2>Response</h2><pre>’ . htmlspecialchars($client->response, ENT_QUOTES) . ‘</pre>’;
echo ‘<h2>Debug</h2><pre>’ . htmlspecialchars($client->getDebug(), ENT_QUOTES) . ‘</pre>’;
?>

[/code]

and is from the official documentation with my values [remote server path + array key/fields] ‘plugged in’.

My script connects to the remote host successfully, but reports the following errors:

[CODE]

Error

Response not of type text/xml: text/plain; charset=utf-8

Request

POST /host/Retail/Retail.asmx/RegistrationCustomer HTTP/1.1
Host: ***.***.***.***
User-Agent: NuSOAP/0.9.5 (1.123)
Connection: Keep-Alive
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: “http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer”
Content-Length: 2184

<?xml version=”1.0″ encoding=”ISO-8859-1″?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/”><SOAP-ENV:Body><ns1474:RegistrationCustomer xmlns:ns1474=”http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer”><CenterId xsi:type=”xsd:string”>20101111111547</CenterId><MemberId xsi:type=”xsd:string”>20101111111547</MemberId><CardNumber xsi:type=”xsd:string”>20101111111547</CardNumber><Title xsi:type=”xsd:string”>Mr</Title><ForeName xsi:type=”xsd:string”>Tim</ForeName><Surname xsi:type=”xsd:string”>Smith</Surname><Sex xsi:type=”xsd:string”>M</Sex><YearOfBirth xsi:type=”xsd:string”>1982</YearOfBirth><NumberOfChildren xsi:type=”xsd:string”>0</NumberOfChildren><EmailAddress xsi:type=”xsd:string”>[email protected]</EmailAddress><Mobile xsi:type=”xsd:string”>20101111111547</Mobile><PhoneNumber xsi:type=”xsd:string”>20101111111547</PhoneNumber><AddressLine1 xsi:type=”xsd:string”>Jordan Street</AddressLine1><AddressLine2 xsi:type=”xsd:string”></AddressLine2><HouseName xsi:type=”xsd:string”></HouseName><HouseNumber xsi:type=”xsd:string”>3</HouseNumber><Postcode xsi:type=”xsd:string”>M15 4PY</Postcode><NumberOfPeopleInHouse xsi:type=”xsd:string”>2</NumberOfPeopleInHouse><Password xsi:type=”xsd:string”>global</Password><Preference xsi:type=”xsd:string”></Preference><HasDrivingLicence xsi:type=”xsd:string”>0</HasDrivingLicence><OwnACar xsi:type=”xsd:string”>0</OwnACar><NumberOfCarsInHouseHold xsi:type=”xsd:string”>1</NumberOfCarsInHouseHold><CarTravelFrequency xsi:type=”xsd:string”>2</CarTravelFrequency><BusTravelFrequency xsi:type=”xsd:string”>3</BusTravelFrequency><TrainTravelFrequency xsi:type=”xsd:string”>4</TrainTravelFrequency><PlaneTravelFreqency xsi:type=”xsd:string”>5</PlaneTravelFreqency><MotorBikeTravelFrequency xsi:type=”xsd:string”>5</MotorBikeTravelFrequency><UniqId xsi:type=”xsd:string”>20101111111547</UniqId></ns1474:RegistrationCustomer></SOAP-ENV:Body></SOAP-ENV:Envelope>

Response

HTTP/1.1 500 Internal Server Error
Server: Microsoft-IIS/5.1
Date: Thu, 11 Nov 2010 11:01:52 GMT
X-Powered-By: ASP.NET
Connection: close
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 60

RegistrationCustomer Web Service method name is not valid.

Debug

2010-11-11 11:15:47.962305 nusoap_client: ctor wsdl= timeout=0 response_timeout=30
endpoint=string(71) “http://82.45.131.110/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer”
2010-11-11 11:15:47.962510 nusoap_client: instantiate SOAP with endpoint at http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer
2010-11-11 11:15:47.962622 nusoap_client: setUseCURL(0)
2010-11-11 11:15:47.962722 nusoap_client: useHTTPPersistentConnection
2010-11-11 11:15:47.963102 nusoap_client: call: operation=RegistrationCustomer, namespace=http://host/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer, soapAction=http://82.45.131.110/FGB_WebSrv/Retail/Retail.asmx/RegistrationCustomer, rpcParams=, style=rpc, use=encoded, endpointType=soap
params=array(29) {
[“CenterId”]=>
string(14) “20101111111547”
[“MemberId”]=>
string(14) “20101111111547”
[“CardNumber”]=>
string(14) “20101111111547”
[“Title”]=>
string(2) “Mr”
[“ForeName”]=>
string(3) “Tim”
[“Surname”]=>
string(5) “Smith”
[“Sex”]=>
string(1) “M”
[“YearOfBirth”]=>
string(4) “1982”
[“NumberOfChildren”]=>
string(1) “0”
[“EmailAddress”]=>
string(26) “[email protected]
[“Mobile”]=>
string(14) “20101111111547”
[“PhoneNumber”]=>
string(14) “20101111111547”
[“AddressLine1”]=>
string(13) “Jordan Street”
[“AddressLine2”]=>
string(0) “”
[“HouseName”]=>
string(0) “”
[“HouseNumber”]=>
string(1) “3”
[“Postcode”]=>
string(7) “M15 4PY”
[“NumberOfPeopleInHouse”]=>
string(1) “2”
[“Password”]=>
string(6) “global”
[“Preference”]=>
string(0) “”
[“HasDrivingLicence”]=>
string(1) “0”
[“OwnACar”]=>
string(1) “0”
[“NumberOfCarsInHouseHold”]=>
string(1) “1”
[“CarTravelFrequency”]=>
string(1) “2”
[“BusTravelFrequency”]=>
string(1) “3”
[“TrainTravelFrequency”]=>
string(1) “4”
[“PlaneTravelFreqency”]=>
string(1) “5”
[“MotorBikeTravelFrequency”]=>
string(1) “5”
[“UniqId”]=>
string(14) “20101111111547”
}

… more
[/CODE]

Also, I need my script to generate a header:

[CODE]
<soap12:Header>
<RetailSoapHeader xmlns=”http://host.org/”>
<Password>string</Password>
<Username>string</Username>
</RetailSoapHeader>
</soap12:Header>

[/CODE]

through the $params array, but am struggling.? Without the header, the script simply won’t work or so i’m told? Also, the server reports: ‘RegistrationCustomer Web Service method name is not valid’ I’m not sure about this?

I’m looking for the browser to display something like:

[CODE]
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version=”1.0″ encoding=”utf-8″?>
<soap12:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope”>
<soap12:Body>
<RegistrationCustomerResponse xmlns=”http://host.org/”>
<RegistrationCustomerResult>
<xsd:schema>schema</xsd:schema>xml</RegistrationCustomerResult>
</RegistrationCustomerResponse>
</soap12:Body>
</soap12:Envelope>
[/CODE]

to confirm success, any ideas? ? Help

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @1cookie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...