Problem with webservice
Posted: Fri Jun 25, 2010 5:32 am
Hi all.
I'm having problems to retrieve info from a web service.
To this address http://webservice.vesseltracker.com/Vtr ... ice?tester there are many forms allowing to send request. I'd like to use php to get infos from the fourth form. The two first fields are username and password, the third one is a number. From their API pdf I got a test login (demoxml / xmldemo). After sending a post from that page I get this answer :
SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:getVesselByIMO xmlns:ns2="http://webservice.ejb.vesseltracker.com/">
<arg0>demoxml</arg0>
<arg1>xmldemo</arg1>
<arg2>5060794</arg2>
</ns2:getVesselByIMO>
</S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getVesselByIMOResponse xmlns:ns2="http://webservice.ejb.vesseltracker.com/">
<return>
<nMMSI>211855000</nMMSI>
<nIMO>5060794</nIMO>
<dAgeMinutes>1.6500666666666666</dAgeMinutes>
<dLat>53.5432</dLat>
<dLon>9.97617</dLon>
<dSoG>0.1</dSoG>
<nWidth>20</nWidth>
<nLength>160</nLength>
<dDraught>5.7</dDraught>
<sName>CAP SAN DIEGO</sName>
<sCallsign>DNAI</sCallsign>
<sDestination>Hamburg</sDestination>
<dtETA>2010-05-07T22:00:00+02:00</dtETA>
<sStatus>moored</sStatus>
<sVesselType>Cargo ship</sVesselType>
</return>
</ns2:getVesselByIMOResponse>
</S:Body>
</S:Envelope>
-------------------------------------
and this is the code I'm trying to invoke the service :
and this is the answer I get :
object(SimpleXMLElement)#3 (1) {
["SFault"]=>
object(SimpleXMLElement)#5 (2) {
["faultcode"]=>
string(8) "S:Client"
["faultstring"]=>
string(214) "Couldn't create SOAP message due to exception: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed."
}
}
------------------------------------------------
Can someone please help me to sort this out?
Thanks in advance
I'm having problems to retrieve info from a web service.
To this address http://webservice.vesseltracker.com/Vtr ... ice?tester there are many forms allowing to send request. I'd like to use php to get infos from the fourth form. The two first fields are username and password, the third one is a number. From their API pdf I got a test login (demoxml / xmldemo). After sending a post from that page I get this answer :
SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:getVesselByIMO xmlns:ns2="http://webservice.ejb.vesseltracker.com/">
<arg0>demoxml</arg0>
<arg1>xmldemo</arg1>
<arg2>5060794</arg2>
</ns2:getVesselByIMO>
</S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getVesselByIMOResponse xmlns:ns2="http://webservice.ejb.vesseltracker.com/">
<return>
<nMMSI>211855000</nMMSI>
<nIMO>5060794</nIMO>
<dAgeMinutes>1.6500666666666666</dAgeMinutes>
<dLat>53.5432</dLat>
<dLon>9.97617</dLon>
<dSoG>0.1</dSoG>
<nWidth>20</nWidth>
<nLength>160</nLength>
<dDraught>5.7</dDraught>
<sName>CAP SAN DIEGO</sName>
<sCallsign>DNAI</sCallsign>
<sDestination>Hamburg</sDestination>
<dtETA>2010-05-07T22:00:00+02:00</dtETA>
<sStatus>moored</sStatus>
<sVesselType>Cargo ship</sVesselType>
</return>
</ns2:getVesselByIMOResponse>
</S:Body>
</S:Envelope>
-------------------------------------
and this is the code I'm trying to invoke the service :
Code: Select all
<?php
$host = "http://webservice.vesseltracker.com/VtrServiceService/VtrService?WDSL";
$soapActionXmlNS = "http://webservice.ejb.vesseltracker.com/";
$soapClient = new SoapClient(NULL,
array(
"location" => $host,
"uri" => "http://schemas.xmlsoap.org/soap/envelope/",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
$soapXml = '
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:getVesselByIMO xmlns:ns2="http://webservice.ejb.vesseltracker.com/">
<arg0>demoxml</arg0>
<arg1>Password</arg1>
<arg2>5060794</arg2>
</ns2:getVesselByIMO>
</S:Body>
</S:Envelope>
';
$response = $soapClient->__doRequest($soapXml, $host, $soapActionXmlNS, "1.0");
$xmlString = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = new SimpleXMLElement($xmlString);
$result = $xml->SBody;
echo '<pre>';
var_dump($result);
echo '</pre>';
?>object(SimpleXMLElement)#3 (1) {
["SFault"]=>
object(SimpleXMLElement)#5 (2) {
["faultcode"]=>
string(8) "S:Client"
["faultstring"]=>
string(214) "Couldn't create SOAP message due to exception: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed."
}
}
------------------------------------------------
Can someone please help me to sort this out?
Thanks in advance