Webservice problem
Posted: Wed Mar 31, 2010 6:15 am
im trying to get my webservice to run but i got an error message i connot seem to solve, i have googled and it doesnt seem to be any good solutions i could use.
the error i get is:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '/home/disk25/otto/dbw_files/opg3.wsdl' : Premature end of data in tag definitions line 3 in /home/disk25/otto/dbw_files/opg3client.php:7 Stack trace: #0 /home/disk25/otto/dbw_files/opg3client.php(7): SoapClient->SoapClient('opg3.wsdl', Array) #1 {main} thrown in /home/disk25/otto/dbw_files/opg3client.php on line 7
i got 3 files opg3client.php which is the client then a server file opg.php and a wsdl file opg3.wsdl
opg3.wsdl:[text]<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="opg3"
targetNamespace="http://localhost/~otto/opg3.php/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://localhost/~otto/opg3.php/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://localhost/~otto/opg3.php/">
<xsd:element name="getProductDescription" type="xsd:string">
</xsd:element>
<xsd:element name="getProductDescriptionresponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string">
<xsd:element name="productDescription" type="xsd:string">
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getPaymentSum" type="xsd:int">
</xsd:element>
<xsd:element name="getPaymentSumResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getOrderTotal" type="xsd:int">
</xsd:element>
<xsd:element name="getOrderTotalResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getBalance" type="xsd:int">
</xsd:element>
<xsd:element name="getbalanceResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getOrdersOnHold">
</xsd:element>
<xsd:element name="getOrdersOnHoldResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="customerNumber" type="xsd:int"
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSalesReport" type="xsd:int">
</xsd:element>
<xsd:element name"getSalesReport">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="month" type="xsd:date"/>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="sum" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getProductDescriptionRequest">
<wsdl:part element="tns:getProductDescription" name="parameters"/>
</wsdl:message>
<wsdl:message name="getProductDescriptionResponse">
<wsdl:part element="getProductDescriptionResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getPaymentSumRequest">
<wsdl:part element="tns:getPaymentSum" name="parameters"/>
</wsdl:message>
<wsdl:message name="getPaymentSumResponse">
<wsdl:part element="getPaymentSumResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getOrderTotalRequest">
<wsdl:part element="tns:getOrderTotal" name="parameters"/>
</wsdl:message>
<wsdl:message name="getOrderTotalResponse">
<wsdl:part element="getOrderTotalResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getBalanceRequest">
<wsdl:part element="tns:getBalance" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBalanceResponse">
<wsdl:part element="getBalanceResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getOrdersOnHoldRequest">
<wsdl:part element="tns:getOrdersOnHold" name="parameters"/>
</wsdl:message>
<wsdl:message name="getOrdersOnHoldResponse">
<wsdl:part element="getOrdersOnHoldResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getSalesReportRequest">
<wsdl:part element="tns:getSalesReport" name="parameters"/>
</wsdl:message>
<wsdl:message name="getSalesReportResponse">
<wsdl:part element="getSalesReportResponse" name"parameters"/>
</wsdl:message>
<wsdl:portType name="opg3">
<wsdl:operation name="getProductDescription">
<wsdl:input message="tns:getProductDescriptionRequest"/>
<wsdl:output message="tns:getProductDescriptionResponse"/>
</wsdl:operation>
<wsdl:operation name="getPaymentSum">
<wsdl:input message="tns:getPaymentSumRequest"/>
<wsdl:output message="tns:getPaymentSumResponse"/>
</wsdl:operation>
<wsdl:operation name="getOrderTotal">
<wsdl:input message="tns:getOrderTotalRequest"/>
<wsdl:output message="tns:getOrderTotalResponse"/>
</wsdl:operation>
<wsdl:operation name="getBalance">
<wsdl:input message="tns:getBalanceRequest"/>
<wsdl:output message="tns:getBalanceResponse"/>
</wsdl:operation>
<wsdl:operation name="getOrdersOnHold">
<wsdl:input message="tns:getOrdersOnHoldRequest"/>
<wsdl:output message="tns:getOrdersOnHoldResponse"/>
</wsdl:operation>
<wsdl:operation name="getSalesReport">
<wsdl:input message="tns:getSalesReportRequest"/>
<wsdl:output message="tns:getSalesReportResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="opg3SOAP" type="tns:opg3">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getProductDescription">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getProductDescription" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getPaymentSum">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getPaymentSum" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOrderTotal">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getOrderTotal" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getBalance">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getBalance" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOrdersOnHold">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getOrdersOnHold" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSalesReport">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getSalesReport" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="opg3">
<wsdl:port binding="tns:opg3SOAP" name="opg3SOAP">
<soap:address location="http://localhost/~otto/opg3.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
[/text]
opg3.php:
opg3client.php:
hope for some response asap 
the error i get is:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '/home/disk25/otto/dbw_files/opg3.wsdl' : Premature end of data in tag definitions line 3 in /home/disk25/otto/dbw_files/opg3client.php:7 Stack trace: #0 /home/disk25/otto/dbw_files/opg3client.php(7): SoapClient->SoapClient('opg3.wsdl', Array) #1 {main} thrown in /home/disk25/otto/dbw_files/opg3client.php on line 7
i got 3 files opg3client.php which is the client then a server file opg.php and a wsdl file opg3.wsdl
opg3.wsdl:[text]<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="opg3"
targetNamespace="http://localhost/~otto/opg3.php/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://localhost/~otto/opg3.php/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://localhost/~otto/opg3.php/">
<xsd:element name="getProductDescription" type="xsd:string">
</xsd:element>
<xsd:element name="getProductDescriptionresponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string">
<xsd:element name="productDescription" type="xsd:string">
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getPaymentSum" type="xsd:int">
</xsd:element>
<xsd:element name="getPaymentSumResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getOrderTotal" type="xsd:int">
</xsd:element>
<xsd:element name="getOrderTotalResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getBalance" type="xsd:int">
</xsd:element>
<xsd:element name="getbalanceResponse" type="xsd:int">
</xsd:element>
<xsd:element name="getOrdersOnHold">
</xsd:element>
<xsd:element name="getOrdersOnHoldResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="customerNumber" type="xsd:int"
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSalesReport" type="xsd:int">
</xsd:element>
<xsd:element name"getSalesReport">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="month" type="xsd:date"/>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="sum" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getProductDescriptionRequest">
<wsdl:part element="tns:getProductDescription" name="parameters"/>
</wsdl:message>
<wsdl:message name="getProductDescriptionResponse">
<wsdl:part element="getProductDescriptionResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getPaymentSumRequest">
<wsdl:part element="tns:getPaymentSum" name="parameters"/>
</wsdl:message>
<wsdl:message name="getPaymentSumResponse">
<wsdl:part element="getPaymentSumResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getOrderTotalRequest">
<wsdl:part element="tns:getOrderTotal" name="parameters"/>
</wsdl:message>
<wsdl:message name="getOrderTotalResponse">
<wsdl:part element="getOrderTotalResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getBalanceRequest">
<wsdl:part element="tns:getBalance" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBalanceResponse">
<wsdl:part element="getBalanceResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getOrdersOnHoldRequest">
<wsdl:part element="tns:getOrdersOnHold" name="parameters"/>
</wsdl:message>
<wsdl:message name="getOrdersOnHoldResponse">
<wsdl:part element="getOrdersOnHoldResponse" name"parameters"/>
</wsdl:message>
<wsdl:message name="getSalesReportRequest">
<wsdl:part element="tns:getSalesReport" name="parameters"/>
</wsdl:message>
<wsdl:message name="getSalesReportResponse">
<wsdl:part element="getSalesReportResponse" name"parameters"/>
</wsdl:message>
<wsdl:portType name="opg3">
<wsdl:operation name="getProductDescription">
<wsdl:input message="tns:getProductDescriptionRequest"/>
<wsdl:output message="tns:getProductDescriptionResponse"/>
</wsdl:operation>
<wsdl:operation name="getPaymentSum">
<wsdl:input message="tns:getPaymentSumRequest"/>
<wsdl:output message="tns:getPaymentSumResponse"/>
</wsdl:operation>
<wsdl:operation name="getOrderTotal">
<wsdl:input message="tns:getOrderTotalRequest"/>
<wsdl:output message="tns:getOrderTotalResponse"/>
</wsdl:operation>
<wsdl:operation name="getBalance">
<wsdl:input message="tns:getBalanceRequest"/>
<wsdl:output message="tns:getBalanceResponse"/>
</wsdl:operation>
<wsdl:operation name="getOrdersOnHold">
<wsdl:input message="tns:getOrdersOnHoldRequest"/>
<wsdl:output message="tns:getOrdersOnHoldResponse"/>
</wsdl:operation>
<wsdl:operation name="getSalesReport">
<wsdl:input message="tns:getSalesReportRequest"/>
<wsdl:output message="tns:getSalesReportResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="opg3SOAP" type="tns:opg3">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getProductDescription">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getProductDescription" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getPaymentSum">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getPaymentSum" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOrderTotal">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getOrderTotal" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getBalance">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getBalance" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOrdersOnHold">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getOrdersOnHold" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSalesReport">
<soap:operation
soapAction="http://localhost/~otto/opg3.php/getSalesReport" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="opg3">
<wsdl:port binding="tns:opg3SOAP" name="opg3SOAP">
<soap:address location="http://localhost/~otto/opg3.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
[/text]
opg3.php:
Code: Select all
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
ini_set("soap.wsdl_cache_ttl", "0"); // disabling WSDL cache
function getProductDescription($request) {
$dbh = new PDC('oci:dbname=//localhost:1521/dbwc', 'db_113', 'db2010');
$sql = "SELECT productname, productdescription FROM products WHERE productcode = ?";
$stmt = $dbh->prepare($sql);
if ($stmt->execute(array($request->productcode))) {
$getproductResult = new StdClass();
while ($row = $stmt->fetch()) {
$getproductResult->string[] = $row[0];
}
}
$res = new StdClass();
$res->getproductResult = $getproductResult;
return $res;
}
function getPaymentSum($request){
$dbh = new PDC('oci:dbname=//localhost:1521/dbwc', 'db_113', 'db2010');
$sql = "SELECT sum(amount)FROM payments WHERE customernumber = ?";
$stmt = $dbh->prepare($sql);
if ($stmt->execute(array($request->customernumber))) {
$paymentSumResult = new StdClass();
while ($row = $stmt->fetch()) {
$paymentSumResult->int[] = $row[0];
}
}
$res = new StdClass();
$res->paymentSumResult = $paymentSumResult;
return $res;
}
function getOrderTotal($request) {
$dbh = new PDC('oci:dbname=//localhost:1521/dbwc', 'db_113', 'db2010');
$sql = "SELECT SUM (quantityordered * priceeach) FROM orders NATURAL JOIN orderdetails WHERE customernumber = ?";
$stmt = $dbh->prepare($sql);
if ($stmt->execute(array($request->customernumber))) {
$ordertotalResult = new StdClass();
while ($row = $stmt->fetch()) {
$ordertotalResult->int[] = $row[0];
}
}
$res = new StdClass();
$res->ordertotalResult = $ordertotalResult;
return $res;
}
function getBalance($request) {
$paymentsum = getPaymentSum($request);
$ordertotal = getOrderTotal($request);
$balance = $paymentsum - $ordertotal;
$res = new StdClass();
$res->balance = $balance;
return $res;
}
function getOrdersOnHold(){
$dbh = new PDC('oci:dbname=//localhost:1521/dbwc', 'db_113', 'db2010');
$sql = "SELECT ordernumber, customernumber FROM orders WHERE status ='On Hold'!";
$ordersOnHold = new StdClass();
foreach ($dbh->query($sql) as $row)
$ordersOnHold->string[] = $row[0];
$res = new StdClass();
$res->ordersOnHold = $ordersOnHold;
return $res;
}
function getSalesReport($request) {
$dbh = new PDC('oci:dbname=//localhost:1521/dbwc', 'db_113', 'db2010');
$sql = "SELECT to_char(paymentdate, 'RRRR-MM'), productname, sum(amount)
FROM (products NATURAL JOIN orderdetails)NATURAL JOIN(customers NATURAL JOIN payments)
WHERE to_char(paymentdate,'RRRR')= ?
GROUP BY to_char(paymentdate,'RRRR-MM'), productname
ORDER BY to_char(paymentdate,'RRRR-MM'), productname";
$stmt = $dbh->prepare($sql);
if ($stmt->execute(array($request->Year))) {
$salesReport = new StdClass();
while ($row = $stmt->fetch()) {
$salesReport->String[] = $row[0];
}
}
$res = new StdClass();
$res->salesReport = $salesReport;
return $res;
}
$server = new SoapServer("opg3.wsdl",
array("soap.wsdl_cache_enabled" => 0,
"soap.wsdl_cache_ttl" => 0));
$server->addFunction("getProductDescription");
$server->addFunction("getPaymentSum");
$server->addFunction("getOrderTotal");
$server->addFunction("getBalance");
$server->addFunction("getOrdersOnHold");
$server->addFunction("getSalesReport");
$server->handle();
?>Code: Select all
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
ini_set("soap.wsdl_cache_ttl", "0"); // disabling WSDL cache
$client = new SoapClient("opg3.wsdl",
array("soap.wsdl_cache_enabled" => 0,
"soap.wsdl_cache_ttl" => 0));
print "Running getProductDescription(\"S700_2834\")<br>";
try {
$query = new StdClass();
$query->productcode = "S700_2834";
$result = $client->getProductDescription($query);
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->productDescriptionResult->string as $name)
print $name . "<br>";
print "Running getPaymentSum(\"406\")<br>";
try {
$query = new StdClass();
$query->customernumber = "406";
$result = $client->getPaymentSum($query);
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->getPaymentSumResult->string as $name)
print $name . "<br>";
print "Running getOrderTotal(\"406\")<br>";
try {
$query = new StdClass();
$query->customernumber = "406";
$result = $client->getOrderTotal($query);
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->getOrderTotalResult->string as $name)
print $name . "<br>";
print "Running getBalance(\"406\")<br>";
try {
$query = new StdClass();
$query->customernumber = "406";
$result = $client->getBalance($query);
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->getBalanceResult->string as $name)
print $name . "<br>";
print "Running getOrdersOnHold()<br>";
try {
$result = $client->getOrdersOnHold();
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->getOrdersOnHoldResult->string as $name)
print $name . "<br>";
print "Running getSalesReport(\"2005\")<br>";
try {
$query = new StdClass();
$query->Year = "2005";
$result = $client->getSalesReport($query);
} catch (SoapFault $soapFault) {
die($soapFault);
}
foreach($result->getSalesReportResult->string as $name)
print $name . "<br>";
?>