I have a class generated with wsdl2apex, which contains some response types, let's say it looks like this:

public class ResponseGetData {
    public SomeDataAttr Data;
    private String[] Data_type_info = new String[]{'Data','<namespace>',null,'0','1','true'};
    private String[] apex_schema_type_info = new String[]{'<namespace>','true','false'};
    private String[] field_order_type_info = new String[]{'Data'};

SomeDataAttr is helper class which was created manually to parse attributes from response XML. It looks like this:

public class SomeDataAttr {
    public String MyType;
    private String[] MyAttrib_att_info = new String[]{'i:mytype'};
    private String[] apex_schema_type_info = new String[]{'<namespace>','true','false'};
    private String[] field_order_type_info = new String[]{};

Body of the resposnse returned from SOAP service looks like this:

    <GetData xmlns="<namespace>">
        <GetDataResult xmlns:a="<namespace-a>" xmlns:b="<namespace-b>" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:Data i:mytype="b:MyDataTypeInfo"> <!-- HERE IS WHAT I NEED -->
                <b:CustomField>Content of this tag does not interest me at all</b:CustomField>

What I need from the response is content of i:mytype attribute (b:MyDataTypeInfo). However, when Data contains any child tags, Salesforce returns error:

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element <namespace-b>=CustomField

Morever, when there are no child tags in Data tag, so it looks like <a:Data i:mytype="b:MyDataTypeInfo"/>, MyType field in SomeDataAttr is still null.

Is there anything I can do about it in APEX? I read that attributes and content can't be deserialized at the same time, but can attributes be correctly deserialized at all?

  • Are you able to share the WSDL in question? Feb 28, 2020 at 7:30
  • Unfortunately no, because it's confidential. However, I don't think it's needed. The issue is that it contains complex types, which wsdl2apex doesn't support. I've flattened the structure of the classes, so all fields from child classes are in parent classes. Anyway, I don't even need content of those classes, only "type" attribute, which indicate type of inheriting class used in the response.
    – kwojt
    Feb 28, 2020 at 10:24
  • OK. For some years now I've been supporting an alternative version of WSDL2Apex that adds support for things like attributes. It's usually much easier to work directly against the WSDL. You can try it directly yourself if you want to see how it handles the attributes - fishofprey.com/2014/11/… Mar 1, 2020 at 19:37

1 Answer 1


Okay, so... I tried to deserialize my attribute in multiple ways, however, in the end, I decided to create HttpRequest to SOAP service and deserialize response manually to get it.

I don't know if responses generated by wsdl2apex can currently be modified in any way to deserialize XML attributes. If anyone has a clue how to do this, please answer.

You must log in to answer this question.

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