Guys,
I have a WSDL I’m trying to consume, but it errors out with:
Fatal error: Uncaught SoapFault exception: [soap:Server] Schema Validation processing failed in C:\www\Engage\soap\consumeWSAPI.php:11 Stack trace: #0 C:\www\Engage\soap\consumeWSAPI.php(11): SoapClient->__soapCall(‘Login’, Array) #1 C:\www\Engage\soap\consumeWSAPI.php(24): comsumewsdl->dorequest() #2 {main} thrown in C:\www\Engage\soap\consumeWSAPI.php on line 11
I belive I’m missing out on Schema Validation, but not sure how to do that. I’d really really appriciate any input in here.
So here is the WSDL:
http://api5.silverpop.com/SoapApi?wsdl
and this is my php login request
<?php
class comsumewsdl {
public $username="xxxxxx";
public $password="xxxxx";
public function dorequest(){
$client = new SoapClient("http://api5.silverpop.com/SoapApi/?wsdl");
$response = $client->__soapCall("Login", array("USERNAME"=>$this->username, "PASSWORD"=>$this->password));
try {
echo "<pre>\
";
echo htmlentities ($response);
echo "\
";
}
catch (SoapFault $exception) {
echo $exception;
}
}
}
$callclass = new comsumewsdl();
$callclass->dorequest();
?>
i’ve still had no joy in getting this to work. anyone else whos maybe done this before or know how to?
thanks oddz i will give that a try.
Although their API doc is saying that a login request should complay to this schema:
Namespace: SilverpopApi:EngageService.SessionMgmt.Login
Schema: SessionMgmt1.xsd
But I’m not sure how I can ensure that my API request complies with that?
AnthonySterling:
Hmm.
The exception then, is thrown by the Login method call, I would think if the Schema was invalid, it would throw one upon instantiation of the client.
Can you call another method? Do you receive a different exception (probably auth related)?
same exception. removing this line of code
$client = new SoapClient(null, array( "location" => "http://api5.silverpop.com/SoapApi/?wsdl", "uri" => "http://schemas.xmlsoap.org/wsdl/soap/", "trace" => 1 ));
returns:
General Exception: Schema Validation processing failed
(:
oddz
June 3, 2010, 11:38am
5
Try loading the schema into a dom document and checking if its actually valid xml. I had a similar problem with UPS wsdl. It turned out the schema was actually invalid. The solution was to use a restful cURL instead sadly.
Hmm.
The exception then, is thrown by the Login method call, I would think if the Schema was invalid, it would throw one upon instantiation of the client.
Can you call another method? Do you receive a different exception (probably auth related)?
Hey Anthony,
I get the same error back, but only better formated lol:
->General Exception: Schema Validation processing failed
anyways i think i’m missing somethin in the validation.
i notice in the swdl right at the top this schema
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="SilverpopApi:Engageservice" xmlns:tns1="SilverpopApi:EngageService.SessionMgmt.Login"
xmlns:tns2="SilverpopApi:EngageService.SessionHeader"
xmlns:tns3="SilverpopApi:EngageService.MailManagement"
xmlns:tns4="SilverpopApi:EngageService.ListMgmt.RecipientActions"
xmlns:tns5="SilverpopApi:EngageService.Reporting"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns6="SilverpopApi:EngageService.ListMgmt.UserActions"
xmlns:tns="SilverpopApi:Engageservice"
xmlns:tns7="SilverpopApi:EngageService.MailManagement.UserActions"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <wsdl:types>
- <xsd:schema>
<xsd:import namespace="SilverpopApi:EngageService.SessionMgmt.Login" schemaLocation="/SoapApi/_resources_/xsd/SessionMgmt1.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.SessionHeader" schemaLocation="/SoapApi/_resources_/xsd/SessionHeader1.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.MailManagement" schemaLocation="/SoapApi/_resources_/xsd/MailMgmt2.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.ListMgmt.RecipientActions" schemaLocation="/SoapApi/_resources_/xsd/ListMgmt2.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.ListMgmt.UserActions" schemaLocation="/SoapApi/_resources_/xsd/ListMgmt-UserActions.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.Reporting" schemaLocation="/SoapApi/_resources_/xsd/Reporting1.xsd" />
<xsd:import namespace="SilverpopApi:EngageService.MailManagement.UserActions" schemaLocation="/SoapApi/_resources_/xsd/MailMgmt-
so i added this line to my original code:
$client = new SoapClient(null, array(
"location" => "http://api5.silverpop.com/SoapApi/?wsdl",
"uri" => "http://schemas.xmlsoap.org/wsdl/soap/",
"trace" => 1 ));
and it now returns with:
->SoapFault exception: [VersionMismatch] Wrong Version in
ohh man i’m slowly, but surley soaping out here
What do you get with this?
<?php
class SilverPopServiceException extends Exception{}
class SilverPopService
{
protected $client;
public function __construct($wsdl){
try{
$this->client = new SoapClient($wsdl);
}catch(Exception $exception){
throw new SilverPopServiceException('Cannot create soap client: ' . $exception->getMessage());
}
}
public function login($username, $password){
return $this->client->Login($username, $password);
}
}
try{
$service = new SilverPopService('http://api5.silverpop.com/SoapApi/?wsdl');
var_dump(
$result = $service->login('username', 'password')
);
}catch(SilverPopServiceException $exception){
echo 'Service Exception: ', $exception->getMessage();
exit;
}catch(Exception $exception){
echo 'General Exception: ', $exception->getMessage();
exit;
}
?>
strange when i do this:
echo $client->__getLastRequest();
it only echos out my password and nothing else, should it not echo out my entie soap envelop?
how do i check what saop format i’m sending over?
guys,
ok i installed soapUI and it generates the envelope for you to send your requests. and this time it worked, so the envelope needs to look like this:
<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/ ” xmlns:sil=“SilverpopApi:EngageService.SessionMgmt.Login”>
<soapenv:Header/>
<soapenv:Body>
<sil:Login>
<sil:USERNAME>xx</sil:USERNAME>
<sil:PASSWORD>xxx</sil:PASSWORD>
</sil:Login>
</soapenv:Body>
</soapenv:Envelope>
but how do I format my php to look like above?
<?php
class comsumewsdl {
public $username="xxxx";
public $password="xxxx";
public $parameters;
public function dorequest(){
//$client = new SoapClient("http://api5.silverpop.com/SoapApi?wsdl", array('trace' => 1));
$client = new SoapClient(null, array(
"location" => "http://api5.silverpop.com/SoapApi?wsdl",
"uri" => "http://schemas.xmlsoap.org/soap/envelope/",
"sil" => "SilverpopApi:EngageService.SessionMgmt.Login",
"trace" => 1 )
);
$this->parameters = array('USERNAME'=>$this->username, 'PASSWORD'=>$this->password);
try {
$response = $client->__soapCall("Login", $this->parameters);
echo "<pre>\
";
echo htmlentities ($response);
echo "\
";
}
catch(Exception $exception){
//$call=$client->__getRequest($response);
echo $client->__getLastRequest();
echo 'General Exception: ', $exception->getMessage();
exit;
}
}
}
$callclass = new comsumewsdl();
$callclass->dorequest();
?>
i think i need to be looking at soapVar and SoapHeader, but I just cannot get this to work. Anyone plz?
ok so,
this is how the xml should look like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:log="SilverpopApi:EngageService.SessionMgmt.Login">
<soapenv:Body>
<log:Login>
<log:USERNAME>username@company.com</log:USERNAME>
<log:PASSWORD userpassword</log:PASSWORD>
</log:Login>
</soapenv:Body>
</soapenv:Envelope>
[/xml]
so am i doing anything different in my php?