• Subbeh
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies

Hi,

 

I have a callout which returns a soap xml message. From within this message I need to extract the following value:

 

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RegisterUserWithAutoIdResponse xmlns="http://website/PartnerRegistrationWebservice/registration"><RegisterUserWithAutoIdResult><registrationResponse clientid="4031972" success="True" xmlns=""><clientName value="Test" success="True" errorCode="0" /><password success="True" errorCode="0" /><loginName value="4031972" success="True" errorCode="0" /></registrationResponse></RegisterUserWithAutoIdResult></RegisterUserWithAutoIdResponse></soap:Body></soap:Envelope>

 

I used the following lines in my Apex script to somehow get this data:

 

string xml = 'the above string'

string XML_STRIP = '(?<=clientid=")([0-9]*+)(?=")';
pattern myPattern = pattern.compile(XML_STRIP);
matcher myMatcher = myPattern.matcher(xml);
xml = myMatcher.replaceAll('');

System.debug('TEST: ' + xml);

 

This however, returns the whole string without the value (clientid). It needs to be the other way around.

 

I tried doing this with XmlStreamReader but that didn't work as the values are inside the tags I think.

 

Any help would be appreciated.

 

 

  • August 25, 2010
  • Like
  • 0

Hi all,

 

I'm new to Salesforce and was just wondering what the best approach would be to create the following situation:

 

We have a daily CSV file containing account information which needs to be imported in Salesforce automatically.

One column of this CSV file contains the account ID's which are similar to the ones in Salesforce so this will be the parent key.

 

Every record in the file contains a certain value, this value needs to be added up to the value in Salesforce for the specific account and parent account.

 

There will probably be more logic added to this, but this is the first step.

 

Any advice is appreciated. Thanks!

  • August 18, 2010
  • Like
  • 0

Hello all,

 

I'm trying to setup a webservice callout in SF. I generated the Apex classes from the WSDL file but when I run it, I get the error:

 

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element registrationResponse.


I've been trying to figure out where the problem is but I can't seem to find it.  I tested the WSDL file in soapUI which works perfectly.

 

This is the code I run in the IDE:

 

 

    registrationweb.RegistrationSoap stub = new registrationweb.RegistrationSoap();
    stub.RegisterUserWithAutoId_test(1234, 'abcd', 'abcd', 'test', 'test');

 

This is the Apex class generated  from the WSDL file:

 

 

//Generated by wsdl2apex

public class registrationweb {

    ...

    public class RegistrationSoap {
        public String endpoint_x = 'http://website.com/PartnerRegistrationWebservice/Registration.asmx';
        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://website.com/PartnerRegistrationWebservice/registration', 'registrationweb'};
        
        ...
        
        public registrationweb.RegisterUserWithAutoId_testResult_element RegisterUserWithAutoId_test(Integer partnerID,String partnerGuid,String partnerPassword,String clientName,String clientPassword) {
            registrationweb.RegisterUserWithAutoId_test_element request_x = new registrationweb.RegisterUserWithAutoId_test_element();
            registrationweb.RegisterUserWithAutoId_testResponse_element response_x;
            request_x.partnerID = partnerID;
            request_x.partnerGuid = partnerGuid;
            request_x.partnerPassword = partnerPassword;
            request_x.clientName = clientName;
            request_x.clientPassword = clientPassword;
            Map<String, registrationweb.RegisterUserWithAutoId_testResponse_element> response_map_x = new Map<String, registrationweb.RegisterUserWithAutoId_testResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://website.com/PartnerRegistrationWebservice/registration/RegisterUserWithAutoId_test',
              'http://website.com/PartnerRegistrationWebservice/registration',
              'RegisterUserWithAutoId_test',
              'http://website.com/PartnerRegistrationWebservice/registration',
              'RegisterUserWithAutoId_testResponse',
              'registrationweb.RegisterUserWithAutoId_testResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.RegisterUserWithAutoId_testResult;
        }
    }
    
    ...
    
    public class RegisterUserWithAutoId_test_element {
        public Integer partnerID;
        public String partnerGuid;
        public String partnerPassword;
        public String clientName;
        public String clientPassword;
        private String[] partnerID_type_info = new String[]{'partnerID','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] partnerGuid_type_info = new String[]{'partnerGuid','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] partnerPassword_type_info = new String[]{'partnerPassword','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] clientName_type_info = new String[]{'clientName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] clientPassword_type_info = new String[]{'clientPassword','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{'partnerID','partnerGuid','partnerPassword','clientName','clientPassword'};
    }
    public class RegisterUserWithAutoId_testResponse_element {
        public registrationweb.RegisterUserWithAutoId_testResult_element RegisterUserWithAutoId_testResult;
        private String[] RegisterUserWithAutoId_testResult_type_info = new String[]{'RegisterUserWithAutoId_testResult','http://website.com/PartnerRegistrationWebservice/registration','RegisterUserWithAutoId_testResult_element','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{'RegisterUserWithAutoId_testResult'};
    }
    public class RegisterUserWithAutoId_testResult_element {
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 

Please help!

 

 

  • August 18, 2010
  • Like
  • 0

Hi,

 

I'm very new to Salesforce, Cloud development, Apex etc. but I'm trying to setup the following:

 

We have a registration webform that communicates with salesforce through web to lead. As soon as a user submits the form, a new Lead is created in Salesforce.

As soon as the new Lead is created, a connection needs to be made to the CMS system where a username and password will be created and returned to Salesforce.

 

There is an API for the CMS system with available WSDL file which I used to create an Apex class.

I created a trigger for Leads called testCallout invoking the ValidateUserPassword method:

 

 

trigger TestCallout on Lead (after insert) {
    for (Lead a : Trigger.new) {
        ComWebservices.CMS_x0020_Live_x0020_ServicesSoap stub = new ComWebservices.CMS_x0020_Live_x0020_ServicesSoap();
        String input = 'Test';
        String output = stub.ValidateUserPassword(input);
    }
}

 This gives me:

"Error: Compile Error: Method does not exist or incorrect signature: stub.ValidateUserPassword(String)"

 

The Apex class is setup like this:

 

 

public class ComWebservices {
    ...
    public class CMS_x0020_Live_x0020_ServicesSoap {
        ...
        public Boolean ValidateUserPassword(Integer userId,String userLogin,String password) {
            ComWebservices.ValidateUserPassword_element request_x = new ComWebservices.ValidateUserPassword_element();
            ComWebservices.ValidateUserPasswordResponse_element response_x;
            request_x.userId = userId;
            request_x.userLogin = userLogin;
            request_x.password = password;
            Map<String, ComWebservices.ValidateUserPasswordResponse_element> response_map_x = new Map<String, ComWebservices.ValidateUserPasswordResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://website.com/webservices/ValidateUserPassword',
              'http://website.com/webservices/',
              'ValidateUserPassword',
              'http://website.com/webservices/',
              'ValidateUserPasswordResponse',
              'ComWebservices.ValidateUserPasswordResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.ValidateUserPasswordResult;
        }
    ...
    }
    ...
}

 

 

 

I tried many different approaches, but as I've never worked with any object oriented language it doesn't really make sense to me.

Is this the right way to invoke webservices?

 

Please help, I've been struggling with this for days now :smileymad:.

 

 

  • August 15, 2010
  • Like
  • 0

Hello all,

 

I'm trying to setup a webservice callout in SF. I generated the Apex classes from the WSDL file but when I run it, I get the error:

 

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element registrationResponse.


I've been trying to figure out where the problem is but I can't seem to find it.  I tested the WSDL file in soapUI which works perfectly.

 

This is the code I run in the IDE:

 

 

    registrationweb.RegistrationSoap stub = new registrationweb.RegistrationSoap();
    stub.RegisterUserWithAutoId_test(1234, 'abcd', 'abcd', 'test', 'test');

 

This is the Apex class generated  from the WSDL file:

 

 

//Generated by wsdl2apex

public class registrationweb {

    ...

    public class RegistrationSoap {
        public String endpoint_x = 'http://website.com/PartnerRegistrationWebservice/Registration.asmx';
        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://website.com/PartnerRegistrationWebservice/registration', 'registrationweb'};
        
        ...
        
        public registrationweb.RegisterUserWithAutoId_testResult_element RegisterUserWithAutoId_test(Integer partnerID,String partnerGuid,String partnerPassword,String clientName,String clientPassword) {
            registrationweb.RegisterUserWithAutoId_test_element request_x = new registrationweb.RegisterUserWithAutoId_test_element();
            registrationweb.RegisterUserWithAutoId_testResponse_element response_x;
            request_x.partnerID = partnerID;
            request_x.partnerGuid = partnerGuid;
            request_x.partnerPassword = partnerPassword;
            request_x.clientName = clientName;
            request_x.clientPassword = clientPassword;
            Map<String, registrationweb.RegisterUserWithAutoId_testResponse_element> response_map_x = new Map<String, registrationweb.RegisterUserWithAutoId_testResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://website.com/PartnerRegistrationWebservice/registration/RegisterUserWithAutoId_test',
              'http://website.com/PartnerRegistrationWebservice/registration',
              'RegisterUserWithAutoId_test',
              'http://website.com/PartnerRegistrationWebservice/registration',
              'RegisterUserWithAutoId_testResponse',
              'registrationweb.RegisterUserWithAutoId_testResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.RegisterUserWithAutoId_testResult;
        }
    }
    
    ...
    
    public class RegisterUserWithAutoId_test_element {
        public Integer partnerID;
        public String partnerGuid;
        public String partnerPassword;
        public String clientName;
        public String clientPassword;
        private String[] partnerID_type_info = new String[]{'partnerID','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] partnerGuid_type_info = new String[]{'partnerGuid','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] partnerPassword_type_info = new String[]{'partnerPassword','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] clientName_type_info = new String[]{'clientName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] clientPassword_type_info = new String[]{'clientPassword','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{'partnerID','partnerGuid','partnerPassword','clientName','clientPassword'};
    }
    public class RegisterUserWithAutoId_testResponse_element {
        public registrationweb.RegisterUserWithAutoId_testResult_element RegisterUserWithAutoId_testResult;
        private String[] RegisterUserWithAutoId_testResult_type_info = new String[]{'RegisterUserWithAutoId_testResult','http://website.com/PartnerRegistrationWebservice/registration','RegisterUserWithAutoId_testResult_element','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{'RegisterUserWithAutoId_testResult'};
    }
    public class RegisterUserWithAutoId_testResult_element {
        private String[] apex_schema_type_info = new String[]{'http://website.com/PartnerRegistrationWebservice/registration','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 

Please help!

 

 

  • August 18, 2010
  • Like
  • 0

Is it possible to run apex datalader from unix platfom?

 

I have a requirement to schedule a dataloader batch job in a unix platform. How can it be done? 

 

Any solutions will be appreciated.