2

I've read several posts on this but have yet to find the correct solution. Basically, using the FuseIT wsdl2APex utility I'm having issues with wsdl definitions like this:

<s:complexType name="Organization">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="unbounded" name="Unit" type="s1:Unit"/>
        <s:element minOccurs="0" maxOccurs="1" name="Employment" type="s1:Employment"/>
        <s:element minOccurs="0" maxOccurs="1" name="Approver" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="Manager" type="s:string"/>
    </s:sequence>
    <s:attribute name="Approvals" type="s:int"/>
</s:complexType>
<s:complexType name="Unit">
    <s:simpleContent>
        <s:extension base="s:string">
            <s:attribute name="Type" type="s:string"/>
        </s:extension>
    </s:simpleContent>
 </s:complexType>

The data class generated results in this:

//Warning: Simple Content Types with Attributes are not supported by WebServiceCallout.invoke
public class Unit {
    public String input;
    public String Type_x;
    private String[] input_type_info = new String[]{'input','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
    public String[] Type_x_att_info = new String[]{'Type'};
    private String[] apex_schema_type_info = new String[]{'urn:Cornerstone:ClientData','true','false'};
    private String[] field_order_type_info = new String[]{};
 } 

The resulting XML sent to the webservice is formed like this:

 <Organization>
     <Unit Type="Division" />
     <Unit Type="Cost Center" />
 </Organization>

Which is missing the unit identifier string ("input" in the APEX code). I need to send this:

<Organization>
    <Unit Type="Division">ExternalDiv1</Unit>
    <Unit Type="Cost Center">CostCenter2</Unit>
</Organization>

What do I need to do to the class to pass the value of the "unit identifier" in the "input" field? It is ignoring that value when generating the output.

Many thanks in advance for any help!

  • Are you able to share your WSDL, or send it through to FuseIT support via the tool? – Daniel Ballinger Jul 27 '15 at 22:37
  • Sure, I will send it through FuseIT support. Thank you!!! – scooterDoodle Jul 28 '15 at 17:05
  • Any chance you've had to look at this? I'm about at my wits end. About ready to build the XML using the DOM, but that's not going to be pretty. Any help would be greatly appreciated!! – scooterDoodle Jul 30 '15 at 21:24
  • Did you see my email that the FuseIT SFDC Explorer tool can be used to generate the XML to send directly via an HttpRequest? I'm reasonably certain that WebServiceCallout. Invoke can't add attributes to base types like strings. – Daniel Ballinger Jul 31 '15 at 8:35
1

The problem is there in the generated warning:

//Warning: Simple Content Types with Attributes are not supported by WebServiceCallout.invoke

The complex type Unit is an extension of the simple type string and it also has the attribute Type. The underlying apex method WebServiceCallout.invoke doesn't support this.

Instead, you can use the FuseIT SFDC Explorer Wsdl2Apex functionality to generate the HttpRequest and required SOAP XML body. When selecting the methods to generate for, use the drop down to the right of the method to select the HttpRequest.


To add the WSSE headers, have a look at Callouts from Salesforce – Adding Soap Headers for WSSE Security. You will need to use the <env:Header> SOAP header to specify the required authentication details.

  • Thanks Daniel, I did do that and I should be able to manipulate the XML with the DOM. Now my issue is the WebService is expecting WSSE, so I need to insert the security into the http header, not sure how I can combine, DOM, Soap and http in the same class. – scooterDoodle Jul 31 '15 at 16:30
  • I've added some more details to the answer. Because you are now building the XML directly it shouldn't be too difficult to add the extra details. – Daniel Ballinger Aug 1 '15 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.