+ Start a Discussion
Karl HuberKarl Huber 

APEX classes generated from WSDL using incorrect namespace for SOAP API callout

Hello,

I've been trying to put together an APEX code library for integrations between Salesforce and Cvent's SOAP API.  I'm having some problems with the SOAP envelope generated by one of the API calls.  It's specifying the wrong namespace at one of the element nodes causing Cvent to fail to deserialize the envelope correctly.

I've tried tweaking the auto-generated classes in APEX (playing around with the apex_schema_type_info and Ids_type_info) to get the correct namespace at the right spot, but so far have had no luck.

Here is the API call I'm trying to make:
//Create an array and store the ids in it
CventWebServiceschemas.IdArray idArray = new CventWebServiceschemas.IdArray();
idArray.Id = updatedResult.Id; //updatedResult is an array of IDs returned from a previous API call

//Make API call to retrieve events
CventWebServiceschemas.RetrieveResult retrieveResult = ws.Retrieve_x('Event' ,idArray);
System.debug('retrieveRes: ' + retrieveResult);

Here are the APEX relevant classes generated when reading in the WSDL:

public CventWebServiceschemas.RetrieveResult Retrieve_x(String ObjectType,CventWebServiceschemas.IdArray Ids) {
            CventWebService.Retrieve_element request_x = new CventWebService.Retrieve_element();
            request_x.ObjectType = ObjectType;
            request_x.Ids = Ids;
            CventWebService.RetrieveResponse_element response_x;
            Map<String, CventWebService.RetrieveResponse_element> response_map_x = new Map<String, CventWebService.RetrieveResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://api.cvent.com/2006-11/Retrieve',
              'http://api.cvent.com/2006-11',
              'Retrieve',
              'http://api.cvent.com/2006-11',
              'RetrieveResponse',
              'CventWebService.RetrieveResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.RetrieveResult;
        }


public class Retrieve_element {
        public String ObjectType;
        public CventWebServiceschemas.IdArray Ids;
        private String[] ObjectType_type_info = new String[]{'ObjectType','http://api.cvent.com/2006-11',null,'1','1','false'};
        private String[] Ids_type_info = new String[]{'Ids','http://schemas.cvent.com/api/2006-11',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://api.cvent.com/2006-11','true','false'};
        private String[] field_order_type_info = new String[]{'ObjectType','Ids'};
    }

public class IdArray {
        public String[] Id;
        private String[] Id_type_info = new String[]{'Id','http://schemas.cvent.com/api/2006-11',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://schemas.cvent.com/api/2006-11','true','false'};
        private String[] field_order_type_info = new String[]{'Id'};
    }


public class RetrieveResponse_element {
        public CventWebServiceschemas.RetrieveResult RetrieveResult;
        private String[] RetrieveResult_type_info = new String[]{'RetrieveResult','http://schemas.cvent.com/api/2006-11',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://api.cvent.com/2006-11','true','false'};
        private String[] field_order_type_info = new String[]{'RetrieveResult'};
    }


The issue I'm having is with the namespace on the idArray in the SOAP envelope.  When I create the API call through C# or .Net WebService Studio, it creates an envelope in the expected format below with the https://schemas.cvent.com/api/2006-11 specified on the <Ids> element.

...
<soap:Body>
  <Retrieve xmlns="http://api.cvent.com/2006-11">
    <ObjectType>Event</ObjectType>
      <Ids xmlns="http://schemas.cvent.com/api/2006-11">
        <Id>7A71F7AC-2EDC-4462-8CF6-46E7CB7BD763</Id>
      </Ids>
  </Retrieve>
</soap:Body>
...

When I do a retrieve call using the APEX generated classes, it's creating the below envelope, which is failing to deserialize since the <Ids> element is inheriting the http://api.cvent.com/2006-11 namespace.

...
<env:Body>
  <Retrieve xmlns="http://api.cvent.com/2006-11">
      <ObjectType>Event</ObjectType>
      <Ids>
        <Id xmlns="http://schemas.cvent.com/api/2006-11">7A71F7AC-2EDC-4462-8CF6-46E7CB7BD763</Id>
      </Ids>
  </Retrieve>
</env:Body>
...

Please let me know if you need any more information (or the full generated APEX classes and full APEX code).  I would have provided both but didn't see any way to upload files.
arpita m 9arpita m 9
Hi Karl,

Did you find the solution for this?

Also could you please tell me how did you get the SOAP envelope in salesforce 

Thanks,
Sujitha
surendrababu ksurendrababu k
Hi Karl,

Did you find Solution on this?

I'm also looking for solution on this.

Thanks
Surendra
Mahesh Somineni 3Mahesh Somineni 3
Hi Kari,

Did you find any solution for this. I am also getting the same issue.Your help will be helpful.

Thanks,
Mahesh
Aaron Bailey 5Aaron Bailey 5
Well, for what little it's worth, my company is having the same issue. Any updates?