Problem with AddSubscriber via WebServices 2.0

Use this forum for questions regarding adoption and functionality of OpenEMM

Moderator: moderator

pixus
Posts: 10
Joined: Tue Dec 04, 2012 4:53 pm

Problem with AddSubscriber via WebServices 2.0

Post by pixus »

Hello everyone,
I have some difficulties in using AddSubscriber with WebServices 2.0
I used without any problem with webservices 1.0

I adapted the way to pass the parameters of the recipient, i put doublecheck = FALSE , i setted the keyColumn, and Overwrite = FALSE...
but I always get customerId = 0 and no subscriber Added.
I setted email, gender and MailType, as the guide suggest.

How can I proceed?
Anything to suggest to help me find the error?

Is there any log I can look into, into the application folder?
Thank you!
pixus
Posts: 10
Joined: Tue Dec 04, 2012 4:53 pm

Re: Problem with AddSubscriber via WebServices 2.0

Post by pixus »

is it maybe necessary to pass all the fields as parameters?
Or is it possible to send only the necessary fields and some others known ?
thank you
vadim
Posts: 2
Joined: Tue Apr 02, 2013 8:48 am

Re: Problem with AddSubscriber via WebServices 2.0

Post by vadim »

I have the similar problem. I've tried with different combinations of parameters and values, but every time I have the following error:
SoapFault exception: [SOAP-ENV:Client] Initial capacity must be greater than 0

With API v.1 it works ok, but API 2.0 not.

Please help.
mdoerschmidt
Posts: 25
Joined: Fri Jan 04, 2013 8:55 am

Re: Problem with AddSubscriber via WebServices 2.0

Post by mdoerschmidt »

Hi!

Doing webservices in PHP could be tricky some time...

There are two problems:
1. Unlike other programming languages (like Java), PHP cannot infer datatypes in some cases, so the developer has to do more work here. That's a common problem.
2. The OpenEMM webservices define a map-type, that uses anyType for keys and values, so you have to specify the correct type in the request. This makes is impossible to use a associative array for the profile fields, an auxiliary class is the solution.


Here is an example code, that adds a subscriber:

Code: Select all

$client = new WsseSoapClient($url, $username, $password);

class ProfileField {
  public $key;
  public $value;

  function __construct( $key, $value) {
    $this->key = $key;
    $this->value = $value;
  }
}

$param = array(
	       new ProfileField( 
				new SoapVar( "email", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"), 
				new SoapVar( "test@example.com", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
				 ),
	       new ProfileField( 
				new SoapVar( "mailtype", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"), 
				new SoapVar( "1", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
				 ),
	       new ProfileField( 
				new SoapVar( "gender", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"), 
				new SoapVar( 0, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
				 )
	       );

$data = array(
	      "parameters" => $param, 
	      "doubleCheck" => true,
	      "keyColumn" => "email",
	      "overwrite" => true
	      );


var_dump($client->AddSubscriber($data));


Best regards,

Markus
Post Reply