Clicky

I want to consume Silverpop's API service.  I added a web reference to my project.  http://api4.silverpop.com/SoapApi?wsdl

I'm using Visual Studio 2010 express for this project

I am using c#.  At this point I am unsure how to use this service.  For example,  how would I login, and read in the session ID I should receive from a successful response?  I am looking to just get pointed in the right direction with some sample code.  

Do I need to build the envelope for each function I want to perform?  If so,  what's the point of the reference?  

Thanks in advance

asked 07/03/2011 02:54

rmartin15's gravatar image

rmartin15 ♦♦


6 Answers:
After adding the web reference you can use:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
SilverPop.EngageSoapApiClientService_InterfaceClient client = new SilverPop.EngageSoapApiClientService_InterfaceClient();
            var session =  client.Login(new SilverPop.LoginRequestType
            {
                USERNAME = "sdfsdfsfsdfsd",
                PASSWORD = "asdadasdas"
            });
            if (session.SUCCESS)
            {
                // You can use session here  : session.SESSIONID
                client.GetSentMailingsForUser(new SilverPop.sessionheadertype
                {
                    sessionid = session.SESSIONID
                }, new SilverPop.GetSentMailingsForUserRequestType
                {
                    // ...  Fill in the options
                });


                client.SendMailing(new SilverPop.SendMailingRequestType
                {
                    MailingId = 11111,
                    RecipientEmail = "test@test.com"
                });
            }


SilverPop is the namespace I gave it when added the service
link
SunnyDark's gravatar image

SunnyDark

Thank you for your response,  that was a lot of help.

I'm headed in the right direction.  I have a followup question,  I tried adapting your example, and I'm still having a little trouble.  I want to take the session id returned from the login and then use it to get a reportID.  I'm getting No overload method for GetReportIDByDate, takes 2 arguments

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
protected void GetTracking()
    {
        SilverPop.EngageSoapApiClientService client = new SilverPop.EngageSoapApiClientService();
        var session = client.Login(new SilverPop.LoginRequestType
        {
            USERNAME = Store.ECommerce.Encryption.Decrypt(ConfigurationManager.AppSettings["ssSilverPopUser"].ToString()),
            PASSWORD = Store.ECommerce.Encryption.Decrypt(ConfigurationManager.AppSettings["ssSilverPopPW"].ToString())
        });
        if (session.SUCCESS)
        {
            string sessionid = session.SESSIONID;
            var reportID = client.GetReportIdByDate(
                new SilverPop.sessionheadertype
                {
                    //sessionid = Session.SessionID
                }, new SilverPop.GetReportIdByDateRequestType
            {
                DATE_START = Convert.ToDateTime(txtSendDate.Text).ToShortDateString() + " 00:00:00",
                DATE_END = Convert.ToDateTime(txtSendDate.Text).AddDays(6).ToShortDateString() + " 23:59:59",
                MAILING_ID = Convert.ToInt64(txtMailingID1.Text)
            } 
            );
            // Then get the resulting ReportID from GetReportIDByDate
            // Make my text box txtReportID.TEXT = the return from the call above.
       
        }
    }
link
rmartin15's gravatar image

rmartin15

Sorry  I miss-commented my code

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
protected void GetTracking()
    {
        SilverPop.EngageSoapApiClientService client = new SilverPop.EngageSoapApiClientService();
        var session = client.Login(new SilverPop.LoginRequestType
        {
            USERNAME = Store.ECommerce.Encryption.Decrypt(ConfigurationManager.AppSettings["ssSilverPopUser"].ToString()),
            PASSWORD = Store.ECommerce.Encryption.Decrypt(ConfigurationManager.AppSettings["ssSilverPopPW"].ToString())
        });
        if (session.SUCCESS)
        {
         //   string sessionid = session.SESSIONID;
            var reportID = client.GetReportIdByDate(
                new SilverPop.sessionheadertype
                {
                    sessionid = Session.SessionID
                }, new SilverPop.GetReportIdByDateRequestType
            {
                DATE_START = Convert.ToDateTime(txtSendDate.Text).ToShortDateString() + " 00:00:00",
                DATE_END = Convert.ToDateTime(txtSendDate.Text).AddDays(6).ToShortDateString() + " 23:59:59",
                MAILING_ID = Convert.ToInt64(txtMailingID1.Text)
            } 
            );
            // Then get the resulting ReportID from GetReportIDByDate
            // Make my text box txtReportID.TEXT = the return from the call above.
       
        }
    }
link
rmartin15's gravatar image

rmartin15

The return type of the GetReportIdByDate function is ReportingResponseType which among other properties has JOB_ID , I guess that is what you need...
Please understand that this is hardly SOAP related , but rather specific to Silver POP API and perhaps you need to consult them or their manual and API reference on how to use their service?


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var reportResponse = client.GetReportIdByDate(new SilverPop.sessionheadertype
                {
                    sessionid = session.SESSIONID
                }, new SilverPop.GetReportIdByDateRequestType
                {
                    DATE_START = Convert.ToDateTime(txtSendDate.Text).ToShortDateString() + " 00:00:00",
                    DATE_END = Convert.ToDateTime(txtSendDate.Text).AddDays(6).ToShortDateString() + " 23:59:59",
                    MAILING_ID = Convert.ToInt64(txtMailingID1.Text)
                });
                if (reportResponse.SUCCESS)
                {
                    if (reportResponse.JOB_STATUS == SilverPop.JobStatus.COMPLETE)
                    {
                        // Use reportResponse.JOB_ID here
                    }
                }
link
SunnyDark's gravatar image

SunnyDark

I'm still running into the overload method for GetReportIDByDate, takes 2 arguments message, but I agree this is more of a Silverpop issue.  Thank you for your help.  I will attempt to resolve the overload error with SIlverpop.  

If I remove the session header code, the error goes away, but the response doesn't return, instead I get a schema has not been validated error.  

This definitely gets me started/
link
rmartin15's gravatar image

rmartin15

Silverpop wasn't much help but I did find the solution.  Just needed to assign the new header before the call.  

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
protected void GetTracking(string myusername,string mypassword)
        {


           
            SilverPop.EngageSoapApiClientService client = new SilverPop.EngageSoapApiClientService();
            var session = client.Login(new SilverPop.LoginRequestType
            {
            USERNAME = myusername,
            PASSWORD=mypassword
            });
            if (session.SUCCESS)
                client.sessionHeader = new SilverPop.sessionheadertype { sessionid = session.SESSIONID };//Assign new session header with valid SessionID
            {

            int MailingID = Convert.ToInt32(txtMailingID1.Text);//User input MailingID
            string StartDate = Convert.ToDateTime(txtSendDate.Text).ToString("MM/dd/yyyy") + " 00:00:00";//Format Start Date
            string EndDate = Convert.ToDateTime(txtSendDate.Text).AddDays(6).ToString("MM/dd/yyyy") + " 23:59:59";//Format Start Date

               var reportResponse = client.GetReportIdByDate(
               new SilverPop.GetReportIdByDateRequestType
                      {
                          MAILING_ID = MailingID,
                          DATE_START = StartDate,
                          DATE_END = EndDate

                      });
                System.Threading.Thread.Sleep(2000);//Wait 2 seconds for response
                if (reportResponse.SUCCESS)
                {
                    int ReportID = Convert.ToInt32(reportResponse.Mailing[0].ReportId.ToString());//Do something here with the ReportID

                }


            }


        }
link
rmartin15's gravatar image

rmartin15

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×21
×156
×1
×8
×18
×13

Asked: 07/03/2011 02:54

Seen: 927 times

Last updated: 07/04/2011 05:43