• jigglypuffly
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I want to be able to retrieve all sendevents from the date range and the subscriber list specified, however, I always get read time out when I do this in Prod. (Works fine in lower region.) How can I improve the architecture so that I can get all of the sendevents I need?
 
<?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <env:Header>
            <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                <UsernameToken>
                    <Username>XXX</Username>
                    <Password>XXX</Password>
                </UsernameToken>
            </Security>
        </env:Header>
        <env:Body>
            <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
                <RetrieveRequest>
                    <ClientIDs><ClientID>XXX</ClientID></ClientIDs>
                    <ObjectType>SentEvent</ObjectType>
                    <Filter xsi:type="ComplexFilterPart">
                        <LeftOperand xsi:type="SimpleFilterPart">
                            <Property>EventDate</Property>
               		   <SimpleOperator>between</SimpleOperator>
               		   <DateValue>2020-05-30T03:00:00.000Z</DateValue>
               		   <DateValue>2020-06-29T02:59:59.999Z</DateValue>
                        </LeftOperand>
                        <LogicalOperator>AND</LogicalOperator>
                       
                                      <RightOperand xsi:type="SimpleFilterPart">
	                                <Property>SubscriberKey</Property>
                            		  <SimpleOperator>IN</SimpleOperator>
                                     <Value>x@gmail.com</Value>
                                     <Value>C_x_y</Value>
                                     <Value>C_x1_y1</Value>
                                     <Value>C_x2_y2</Value>
                                     <Value>t</Value>
                                     <Value>dd@d.com</Value>

                                      </RightOperand>
                         
                    </Filter>
                    <Properties>SendId</Properties>
                    <Properties>BatchId</Properties>
                    <Properties>TriggeredSendDefinitionObjectID</Properties>
                    <Properties>EventType</Properties>
                   
                </RetrieveRequest>
            </RetrieveRequestMsg>
        </env:Body>
    </env:Envelope>

 
How to construct a security WSSE header in APEX code to make a SOAP call out?
This is the XML that I am trying to reproduce. 
<soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>USERNAME</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
</soapenv:Header>

SOAP object class (WSDL2Apex):
... 
public class Soap {
        public SFMC_SOAP_TO_SF_SECURITY.SecurityHeader securityHeader = new SFMC_SOAP_TO_SF_SECURITY.SecurityHeader('USERNAME', 'PASSWORD');
        private String Security_hns = 'Security=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
        public String endpoint_x = 'HIDDEN FOR PRIVACY';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://exacttarget.com/wsdl/partnerAPI', 'SFMC_SOAP_TO_SF_API'};
        public SFMC_SOAP_TO_SF_API.VersionInfoResponseMsg_element VersionInfo(Boolean IncludeVersionHistory) {
            SFMC_SOAP_TO_SF_API.VersionInfoRequestMsg_element request_x = new SFMC_SOAP_TO_SF_API.VersionInfoRequestMsg_element();
            request_x.IncludeVersionHistory = IncludeVersionHistory;
            SFMC_SOAP_TO_SF_API.VersionInfoResponseMsg_element response_x;
            Map<String, SFMC_SOAP_TO_SF_API.VersionInfoResponseMsg_element> response_map_x = new Map<String, SFMC_SOAP_TO_SF_API.VersionInfoResponseMsg_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'VersionInfo',
              'http://exacttarget.com/wsdl/partnerAPI',
              'VersionInfoRequestMsg',
              'http://exacttarget.com/wsdl/partnerAPI',
              'VersionInfoResponseMsg',
              'SFMC_SOAP_TO_SF_API.VersionInfoResponseMsg_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
public SFMC_SOAP_TO_SF_API.RetrieveResponseMsg_element Retrieve_x(SFMC_SOAP_TO_SF_API.RetrieveRequest RetrieveRequest) {
            SFMC_SOAP_TO_SF_API.RetrieveRequestMsg_element request_x = new SFMC_SOAP_TO_SF_API.RetrieveRequestMsg_element();
            request_x.RetrieveRequest = RetrieveRequest;
            SFMC_SOAP_TO_SF_API.RetrieveResponseMsg_element response_x;
            Map<String, SFMC_SOAP_TO_SF_API.RetrieveResponseMsg_element> response_map_x = new Map<String, SFMC_SOAP_TO_SF_API.RetrieveResponseMsg_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'Retrieve',
              'http://exacttarget.com/wsdl/partnerAPI',
              'RetrieveRequestMsg',
              'http://exacttarget.com/wsdl/partnerAPI',
              'RetrieveResponseMsg',
              'SFMC_SOAP_TO_SF_API.RetrieveResponseMsg_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
}
...

Security Header class
public class SFMC_SOAP_TO_SF_SECURITY 
{

    public class UsernameToken {
        // Constructor for UsernameToken used to pass in username and password parameters
        public UsernameToken(String username, String password)
        {
            this.Username = username;
            this.Password = new password_e(password);
        }

        public String Username;
        public password_e Password;
        private String[] Username_type_info = new String[]{'Username','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'Username','Password'};

    }
    
        public class password_e{
            public password_e(String password) {
                this.password = password;
                type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText';             
    	}

            public String password;
            public string type; 
            public String[] type_att_info = new String[]{'Type'};        
            private String[] password_type_info = new String[]{'Password','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText','string','1','1','false'};
            private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
            private String[] field_order_type_info = new String[]{'password'};
    }

    
    
    // SecurityHeaderType Class
    public class SecurityHeaderType 
    {       
        // Constructor for SecurityHeaderType used to pass in username and password parameters and instantiate the UsernameToken object     
        public SecurityHeaderType(String username, String password)
        {
            this.UsernameToken = new SFMC_SOAP_TO_SF_SECURITY.UsernameToken(username, password);
        }

        public String wsuNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';              
        public SFMC_SOAP_TO_SF_SECURITY.UsernameToken UsernameToken;
        private String[] UsernameToken_type_info = new String[]{'UsernameToken','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','UsernameToken','1','1','false'};
        private String[] wsuNamespace_att_info = new String[]{'xmlns:wsu'};               
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'UsernameToken'};
    }
    

    public class SecurityHeader{
        
        public SecurityHeader(String username, String password){
            this.headerPackager = new SFMC_SOAP_TO_SF_SECURITY.SecurityHeaderType(username, password);
        }
    
        public String wsseNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
        public SFMC_SOAP_TO_SF_SECURITY.SecurityHeaderType headerPackager;
		private String[] wsseNamespace_att_info = new String[]{'xmlns:wsse'};               
		private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
		private String[] field_order_type_info = new String[]{'Security'}; 
        
    }
}