SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: SOAP Help

  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SOAP Help

    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:
    Code:
    http://api5.silverpop.com/SoapApi?wsdl
    and this is my php login request
    PHP Code:
    <?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>\n";     
            echo 
    htmlentities ($response); 
            echo 
    "\n";   
        } 
        catch (
    SoapFault $exception) {     
                echo 
    $exception;         
            } 
        }
    }

    $callclass  = new comsumewsdl();
    $callclass->dorequest();
    ?>

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What do you get with this?
    PHP Code:
    <?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;
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Code:
    <?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:

    PHP Code:
    $client = new SoapClient(null, array(
          
    "location" => "http://api5.silverpop.com/SoapApi/?wsdl",
          
    "uri"      => "http://schemas.xmlsoap.org/wsdl/soap/"
          
    "trace"    => )); 
    and it now returns with:

    ->SoapFault exception: [VersionMismatch] Wrong Version in

    ohh man i'm slowly, but surley soaping out here

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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)?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    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
    PHP Code:
     $client = new SoapClient(null, array(       "location" => "http://api5.silverpop.com/SoapApi/?wsdl",       "uri"      => "http://schemas.xmlsoap.org/wsdl/soap/",       "trace"    => )); 
    returns:

    General Exception: Schema Validation processing failed


  6. #6
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so,
    this is how the xml should look like:

    [code]
    <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?

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,187
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    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.
    The only code I hate more than my own is everyone else's.

  8. #8
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  9. #9
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  10. #10
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Code:
    <?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"    => )
                             ); 


    $this->parameters = array('USERNAME'=>$this->username'PASSWORD'=>$this->password);


    try { 
            
    $response $client->__soapCall("Login"$this->parameters);
            echo 
    "<pre>\n";     
            echo 
    htmlentities ($response); 
            echo 
    "\n";   
        } 
        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?

  11. #11
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've still had no joy in getting this to work. anyone else whos maybe done this before or know how to?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •