We used a WSDL and generated an Apex class from that WSDL. Since there were multiple namespaces in the WSDL, we gave a common class name. (as recommended in SFDC) Once the Apex class was generated it had the correct namespaces as expected. However when we try to invoke a backend billing system by generating a request XML using this class, we do not get the namespaces as expected.

Example: in our case all elements have different namespaces inside the same request XML. However there is no namespace generated to the elements in the request rather a namespace generated for the request message. This is incorrect as we need to a correct namespace mentioned for every element and in fact in APEX class its generated correctly as well.

  • Are you able to share your WSDL? It will make it much easier to examine the required callout XML structure. Feel free to change the endpoint to something like example.com if you need to. Also, there should be one Apex Class per namespace. Where does Salesforce recommend you have a common class name? Commented Jul 31, 2014 at 10:10
  • With regards to the common class name, I found the comment on the "Step 2: Specify Class Names" page about how multiple namespaces could be combined into a single Apex Class. Have you tried not combining the schemas into a single class? Commented Aug 2, 2014 at 9:52

1 Answer 1


We had a simular problem and we contacted SF support. They said that WSDL to Apex doesn't support referencing elements from a different namespace.

Apex supports the following schema constructs:

  • xsd:all, in Apex code saved using API version 15.0 and later
  • xsd:annotation, in Apex code saved using API version 15.0 and later
  • xsd:attribute, in Apex code saved using API version 15.0 and later
  • xsd:choice, in Apex code saved using API version 15.0 and later
  • xsd:element. In Apex code saved using API version 15.0 and later, the ref attribute is also supported with the following restrictions:
    • You cannot call a ref in a different namespace.

Document about the wsdl 2 apex: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex.htm

So if you cannot change the element's namespace, the other alternative is to rely on a regular HTTP callout (as opposed to an Apex web service callout)

Info/links about HTTP callouts:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .