logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Accessing web service problem: msg#00059

Subject: Re: Accessing web service problem
Below is code that works (for me, at least).  Some things I did

1. Use the WSDL from the service!  This helps NuSOAP know how to serialize the 
message without you having to tell it everything.

2. The ServiceRequest operation has an input message with a single part named 
'parameters' which is a ServiceRequest element.  The ServiceRequest element is 
a complexType with a single element named RequestXML.  I in turn assign the XML 
string to a variable, construct the array corresponding to a ServiceRequest 
element, then make the call with a single parameter named 'parameters'.

<?php
require_once('../lib/nusoap.php');
$client = new soapclient('http://62.105.109.66/HCGService.asmx?wsdl', true);
$requestxml = '
<HCGRequest>
    <requestType>SC</requestType>
    <partnerID>36ED7B47-158E-4E94-83F6-3E819159491C</partnerID>
</HCGRequest>
';
$ServiceRequest = array('RequestXML' => $requestxml);
$result = $client->call('ServiceRequest', array('parameters' => 
$ServiceRequest));
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>';
?>

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Bob Harrison" <contact@xxxxxxxxxxxxxxx>
To: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, February 17, 2005 9:11 AM
Subject: [Nusoap-general] Accessing web service problem


Hi,
I am very new to SOAP and NuSOAP and have a problem accessing a webservice
that I'd like some help on if possible.
I have included as much information as possible below so I hope this makes
things easy to understand.

Installation of nusoap was easy and no problem.

Below is the code I am using to access the webservice which should pull back
a load of regional information for the UK.

-------- The php code ---------
<?php
// Pull in the NuSOAP code
require_once('./lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://62.105.109.66/HCGService.asmx');
//set the body info
$body = '
<HCGRequest>
    <requestType>SC</requestType>
    <partnerID>36ED7B47-158E-4E94-83F6-3E819159491C</partnerID>
</HCGRequest>
';

//serlialise the envelope
$msg = $client->serializeEnvelope($body);
//send the message
$result = $client->send($msg,'http://62.105.109.66/HCGService.asmx');
//print the php result
print_r ($result);
//Show the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>

------ End of code -------


You can see it in action at:
http://wedding-stationary.co.uk/new1.php

I get this error:
Array ( [faultcode] => soap:Client [faultstring] => Server did not recognize
the value of HTTP Header SOAPAction: http://62.105.109.66/HCGService.asmx.
[detail] => ) 
plus others back from the server (see link).


This is the USER GUIDE information I got from the company who runs the
webservice. 
(my partnerID no. is 36ED7B47-158E-4E94-83F6-3E819159491C):


------ User Guide start -------

Web Service Interface
    The web service¹s IP address is 62.105.109.66/HCGService.asmx and its
name is HCGWebService. It contains a public class called HCGService which
has a single public facing method called ServiceRequest. The input parameter
of this method is called RequestXML. Both the input and output of this
method are strings in XML format, details of which are given below.
    The web service must be accessed using SOAP. Requests can be made
synchronously or asynchronously.

Partner Set Up
    In order to use the web service a partner requires a web service ID.
This takes the form of a globally unique identifier (GUID) which must be
included in every request made to the web service. These GUIDs are obtained
upon request. 

Request Types
    There are four types of request which can be made to the web service:
        1. Countries and Regions (SC)
        2. Property List (GR)
        3. Property Details (FD)
        4. Property Availability (AQ)
    Details of the required input XML formats and the resultant output XML
formats are given below for each of these request types. All requests of any
type are enclosed in a root XML node called ³HCGRequest² which always
contains child nodes called ³requestType² and ³partnerID². The contents of
the ³requestType² node specify which of the four request types to run using
the codes given in parentheses in the list above. The ³partnerID² node
contains the calling partner¹s web service ID (i.e. the GUID referred to in
section Partner Set Up above.) Similarly, all responses are enclosed in a
root node called ³HCGResponse² which contains child nodes called
³responseType² and ³partnerTelNo². The former reiterates the request type
code and the latter gives the calling partner¹s booking telephone number. If
this is not found ³UNKNOWN² is returned.

    Countries and Regions
    This request type returns details of the countries and regions
containing properties associated with the calling partner. It also returns
the minimum and maximum number of people which can be accommodated by those
properties.

Request example:
<HCGRequest>
    <requestType>SC</requestType>
    <partnerID>36ED7B47-158E-4E94-83F6-3E819159491C</partnerID>
</HCGRequest>

Response example:
<HCGResponse>
    <partnerTelNo>01756 12345678</partnerTelNo>
    <responseType>SC</responseType>
    <country countryName="United Kingdom" countryCode="GB">
       <region regionName="Wales" regionCode="GB19" parentCode="GB">
          <region regionName="Anglesey" regionCode="CCK" parentCode="GB19"/>
          <region regionName="Snowdonia" regionCode="CCJ"
parentCode="GB19"/>
       </region>
       <region regionName="Cornwall" regionCode="GB2" parentCode="GB">
          <region regionName="South Cornwall" regionCode="BDJ"
parentCode="GB2"/>
       </region>
    </country>
    <sleeps>
       <sleep>2</sleep>
       <sleep>20</sleep>
    </sleeps>
</HCGResponse>

------ User guide end -------

Any help would be great. As I say I'm new to all the xml stuff and would
prefer to use php and mysql but the company is changing to xml. They don't
have much (if any) technical help and certainly don't know about NuSoap etc.
I know that NuSOAP can do it but just need to find out how.

Any suggestions?

Many thanks

Bob Harrison
contact@xxxxxxxxxxxxxxx



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Nusoap-general mailing list
Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/nusoap-general



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click


<Prev in Thread] Current Thread [Next in Thread>