Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP SOAP WebService WSDL
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 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
 
<?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 3-Feb-13 1:24am
Edited 3-Feb-13 1:40am
v3

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

  Print Answers RSS
0 OriginalGriff 230
1 PIEBALDconsult 150
2 DamithSL 125
3 BillWoodruff 108
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100