Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 582

How to use webservices in php using soap

$
0
0

Hi all ,

I have a wevservice link say http://abc.com/wscom/MKWebService.rem from where I am trying to return value giving some parameters . The method and parameters are given below.

method : GetInfo

Parameters:

string LicenseID
string password

Return Value:

struct AnswerInt

Now I have two xml files request.xml and response.xml as

//request.xml

<?xml version="1.0" encoding="utf-8"?>
POST /dotnet/lodge.asmx HTTP/1.1
Host: www.messagenet.com.au
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>
    <LodgeMessage xmlns="http://abc.com/wscom/MKWebService.rem">
      <LicenceID>string</LicenceID>
      <password>string</password>
     </LodgeMessage>
  </soap12:Body>
</soap12:Envelope>

//response.xml

<?xml version="1.0" encoding="utf-8"?>
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>
    <LodgeMessageResponse xmlns="http://abc.com/wscom/MKWebService.rem">
      <LodgeMessageResult>string</LodgeMessageResult>
    </LodgeMessageResponse>
  </soap12:Body>
</soap12:Envelope>

//and php file rpc.php code is :
<php

$client = new SoapClient("http://abc.com/wscom/MKWebService.rem");
    $licenceid="LicenseID";
    $password="password";

    $result = $client->LodgeMessage(array(
        "LicenceID" => $licenceid,
        "password" => $password,
    ));


    $response_arr = objectToArray($result);

    echo "return_code= " . str_replace(";", "", $response_arr["LodgeMessageResult"]);

    function objectToArray($d)
    {
        if (is_object($d))
        {
            $d = get_object_vars($d);
        }

        if (is_array($d))
        {
            return array_map(__FUNCTION__, $d);
        }
        else
        {
            return $d;
        }
    }

?>

Error:
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load

How to resolve this . Urgent

Subrata


Viewing all articles
Browse latest Browse all 582

Latest Images

Trending Articles



Latest Images