function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TezynTezyn 

How can I populate the value of an xml element, when performing a Apex external Web call?

I have the following APEX class that was generated from a WSDL:

//Generated by wsdl2apex

public class soapBigmachinesCom {
    public class SecurityServicePort {
        public String endpoint_x = 'https://testEnvironment.bigmachines.com/v1_0/receiver';
        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;
        public soapBigmachinesCom.category_element category;
        public soapBigmachinesCom.xsdInfo_element xsdInfo;
        private String category_hns = 'category=urn:soap.bigmachines.com';
        private String xsdInfo_hns = 'xsdInfo=urn:soap.bigmachines.com';
        private String[] ns_map_type_info = new String[]{'urn:soap.bigmachines.com', 'soapBigmachinesCom'};
        public soapBigmachinesCom.loginResponse_element login(soapBigmachinesCom.LoginRequestUserInfoType userInfo) {
            soapBigmachinesCom.login_element request_x = new soapBigmachinesCom.login_element();
            soapBigmachinesCom.loginResponse_element response_x;
            request_x.userInfo = userInfo;
            Map<String, soapBigmachinesCom.loginResponse_element> response_map_x = new Map<String, soapBigmachinesCom.loginResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:soap.bigmachines.com',
              'login',
              'urn:soap.bigmachines.com',
              'loginResponse',
              'soapBigmachinesCom.loginResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
    public class category_element {
        public String actor;
        public String mustUnderstand;
        private String[] actor_att_info = new String[]{'actor'};
        private String[] mustUnderstand_att_info = new String[]{'mustUnderstand'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{};
    }
    public class loginResponse_element {
        public soapBigmachinesCom.CommonStatusType status;
        public soapBigmachinesCom.LoginResponseUserInfo userInfo;
        private String[] status_type_info = new String[]{'status','urn:soap.bigmachines.com','CommonStatusType','1','1','false'};
        private String[] userInfo_type_info = new String[]{'userInfo','urn:soap.bigmachines.com','LoginResponseUserInfo','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'status','userInfo'};
    }
    public class LoginResponseUserInfo {
        public String sessionCurrency;
        public String sessionId;
        public String actor;
        public String mustUnderstand;
        private String[] sessionCurrency_type_info = new String[]{'sessionCurrency','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] actor_att_info = new String[]{'actor'};
        private String[] mustUnderstand_att_info = new String[]{'mustUnderstand'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'sessionCurrency','sessionId'};
    }
    public class LoginRequestUserInfoType {
        public String username;
        public String password;
        public String sessionCurrency;
        public String sso;
        private String[] username_type_info = new String[]{'username','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] password_type_info = new String[]{'password','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] sessionCurrency_type_info = new String[]{'sessionCurrency','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] sso_type_info = new String[]{'sso','urn:soap.bigmachines.com','BooleanOrBlank','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'username','password','sessionCurrency','sso'};
    }
    public class xsdInfo_element {
        public String schemaLocation;
        public String actor;
        public String mustUnderstand;
        private String[] schemaLocation_type_info = new String[]{'schemaLocation','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] actor_att_info = new String[]{'actor'};
        private String[] mustUnderstand_att_info = new String[]{'mustUnderstand'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'schemaLocation'};
    }
    public class CommonStatusType {
        public String success;
        public String message;
        public Integer records_read;
        public Integer records_failed;
        public Integer records_deleted;
        public Integer records_returned;
        public String detail;
        public String warning;
        private String[] success_type_info = new String[]{'success','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] message_type_info = new String[]{'message','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] records_read_type_info = new String[]{'records_read','http://www.w3.org/2001/XMLSchema','int','0','1','true'};
        private String[] records_failed_type_info = new String[]{'records_failed','http://www.w3.org/2001/XMLSchema','int','0','1','true'};
        private String[] records_deleted_type_info = new String[]{'records_deleted','http://www.w3.org/2001/XMLSchema','int','0','1','true'};
        private String[] records_returned_type_info = new String[]{'records_returned','http://www.w3.org/2001/XMLSchema','int','0','1','true'};
        private String[] detail_type_info = new String[]{'detail','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] warning_type_info = new String[]{'warning','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'success','message','records_read','records_failed','records_deleted','records_returned','detail','warning'};
    }
    public class fault_element {
        public String exceptionCode;
        public String exceptionMessage;
        public String exceptionDescription;
        private String[] exceptionCode_type_info = new String[]{'exceptionCode','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] exceptionMessage_type_info = new String[]{'exceptionMessage','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] exceptionDescription_type_info = new String[]{'exceptionDescription','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'exceptionCode','exceptionMessage','exceptionDescription'};
    }
    public class login_element {
        public soapBigmachinesCom.LoginRequestUserInfoType userInfo;
        private String[] userInfo_type_info = new String[]{'userInfo','urn:soap.bigmachines.com','LoginRequestUserInfoType','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:soap.bigmachines.com','true','true'};
        private String[] field_order_type_info = new String[]{'userInfo'};
    }
}

 

Which when called as follows:

soapBigmachinesCom.LoginRequestUserInfoType sbmUI = new soapBigmachinesCom.LoginRequestUserInfoType();
sbmUI.username = 'test';
sbmUI.password = 'test';
soapBigmachinesCom.SecurityServicePort ssp = new soapBigmachinesCom.SecurityServicePort();
soapBigmachinesCom.category_element ce = new soapBigmachinesCom.category_element();

ssp.category = ce;
soapBigmachinesCom.xsdInfo_element ie = new soapBigmachinesCom.xsdInfo_element();
ie.schemaLocation = 'https://testenvironment.bigmachines.com/bmfsweb/testenvironment/schema/v1_0/security/Security.xsd';
ssp.xsdInfo = ie;

soapBigmachinesCom.loginResponse_element response = ssp.login(sbmUI);

 

creates the following request:

<?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>
    <category xmlns="urn:soap.bigmachines.com" />
    <xsdInfo xmlns="urn:soap.bigmachines.com">
      <schemaLocation>https://testenvironment.bigmachines.com/bmfsweb/testenvironment/schema/v1_0/security/Security.xsd</schemaLocation>
    </xsdInfo>
  </env:Header>
  <env:Body>
    <login xmlns="urn:soap.bigmachines.com">
    <userInfo>
        <username>test</username>
        <password>test</password>
        <sessionCurrency xsi:nil="true" />
        <sso xsi:nil="true" />
      </userInfo>
    </login>
</env:Body>
</env:Envelope>

 

How can I change my class (or how can I call it) to populate the category element value?

<category xmlns="urn:soap.bigmachines.com" />

 

to

<category xmlns="urn:soap.bigmachines.com" >Security</category>

 

Harika ZillaHarika Zilla
Iam also using the BigMachines API and having the same issue as you mentioned in the post.
Did you find any solution to populate category element value?