Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am making a web service for the first time. Im getting this exception

SoapFault exception: [HTTP] Unable to parse URL in C:\wamp\www\Assignment 8\client.php:22 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('getUserData', Array) #2 C:\wamp\www\Assignment 8\client.php(22): SoapClient->getUserData('1') #3 {main}


I google the exception too but did'nt solve it yet

This is my WSDL file code

XML
<?xml version='1.0' encoding='UTF-8'?>

<wsdl:definitions name="UserInfo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="UserInfo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="UserInfo" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  >

  <wsdl:message name="userDataRequest">
   <wsdl:part name="id" type="xsd:string"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="userDataResponse">
   <wsdl:part name="firstName" type="xsd:string"></wsdl:part>
  </wsdl:message>

  <wsdl:portType name="UserInfo">
    <wsdl:operation name="getUserData">
      <wsdl:input message="tns:userDataRequest"/>
      <wsdl:output message="tns:userDataResponse"/>
    </wsdl:operation>
 </wsdl:portType>

  <wsdl:binding name="UserInfo" type="tns:UserInfo">
   <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
   <wsdl:operation name="getUserData">
    <soap:operation soapAction="server.php" />
    <wsdl:input>
     <soap:body use="literal" namespace="UserInfo" />
    </wsdl:input>
    <wsdl:output>
     <soap:body use="literal" namespace="UserInfo" />
    </wsdl:output>
   </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="UserInfo">
    <wsdl:port binding="tns:UserInfo" name="YUserInfo">
      <soap:address location="server.php" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


This is client.php file code

XML
<?php
   ini_set("soap.wsdl_cache_enabled", "0");
   $client = new SoapClient("assign8.wsdl",array(
    "trace"      => 1,
    "exceptions" => 0));
    print($client->getUserData("1"));
     print "<pre>\n";
  print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
  print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
  print "</pre>";
?>




and this is server.php code

function getUserData($id)
{
$array = array('firstName'=>'ASma');
return $array;
}

ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("assign8.wsdl");
$server->addFunction("getUserData");
$server->handle();
?>
Posted
Updated 3-Feb-13 0:40am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900