You need to sign in to do that
Don't have an account?
rchoi_zuora
Is there a way in WSDL2Apex-generated code to include custom XML attributes?
Hi Wonderful Force.com Community!
Question: I'm working with my team to import our Zuora WSDL into Salesforce. It's a lot like the salesforce WSDL -- a base object named zObject, different sub-objects, and a create() call. The Apex2WSDL code works great -- it creates an Account object, the create() call, and even the create element wrapper.
The callout works as well, but it's missing one thing -- a type attribute on the zObject. For example, the XML looks like:
<?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><SessionHeader xmlns="http://api.zuora.com/"><session>BLAH</session></SessionHeader></env:Header><env:Body><create xmlns="http://api.zuora.com/"><zObjects><AccountNumber xsi:nil="true" xmlns="http://object.api.zuora.com/" /><Name xmlns="http://object.api.zuora.com/">Dev Test 1</Name></zObjects></create></env:Body></env:Envelope>
As you might imagine, I want to have the XML be:
<?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><SessionHeader xmlns="http://api.zuora.com/"><session>BLAH</session></SessionHeader></env:Header><env:Body><create xmlns="http://api.zuora.com/"><zObjects type="Account"><AccountNumber xsi:nil="true" xmlns="http://object.api.zuora.com/" /><Name xmlns="http://object.api.zuora.com/">Dev Test 1</Name></zObjects></create></env:Body></env:Envelope>
But I can't seem to figure out how to add the type="Account" part. I tweaked the generated code (messing with Account.apex_schema_type and create_element.zObjects_type_info, yes, a hack) but neither did anything useful. I included the generated code below, in case it's useful.
I guess it comes down to one question: is there a way in the auto-generated code to include custom XML attributes? And if so, what is it?
Thanks in advance!
*r*
------------------
GENERATED CODE:
public class Account extends ZObject {
public String AccountNumber;
public String Name;
private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Name_type_info = new String[]{'Name','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://object.api.zuora.com/','true','true'};
private String[] field_order_type_info = new String[]{'AccountNumber','Name'};
}
public apiZuoraCom.SaveResult[] create(objectApiZuoraCom.zObject[] zObjects) {
apiZuoraCom.create_element request_x = new apiZuoraCom.create_element();
apiZuoraCom.createResponse_element response_x;
request_x.zObjects = zObjects;
Map<String, apiZuoraCom.createResponse_element> response_map_x = new Map<String, apiZuoraCom.createResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://api.zuora.com/',
'create',
'http://api.zuora.com/',
'createResponse',
'apiZuoraCom.createResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.result;
}
public class create_element {
public objectApiZuoraCom.zObject[] zObjects;
private String[] zObjects_type_info = new String[]{'zObjects', 'http://object.api.zuora.com','zObject','0','-1','false'};
private String[] apex_schema_type_info = new String[]{'http://api.zuora.com/','true','true'};
private String[] field_order_type_info = new String[]{'zObjects'};
}
GENERATED XML
<?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><SessionHeader xmlns="http://api.zuora.com/"><session>BLAH</session></SessionHeader></env:Header><env:Body><create xmlns="http://api.zuora.com/"><zObjects><AccountNumber xsi:nil="true" xmlns="http://object.api.zuora.com/" /><Name xmlns="http://object.api.zuora.com/">Dev Test 1</Name></zObjects></create></env:Body></env:Envelope>