function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pfarrellpfarrell 

Salesforce SOA output element

I wanted to verify that my findings are accurate. Can I have multiple sequence elements in the object output by my WSDL when generating APEX code? I am working with an existing WSDL and would like to utilize it within Apex. I get the following error when autogenerating Apex code from the WSDL

Unsupported WSDL. Operation '[operation name]' has more than one output element.

I tweaked the WSDL until I got it working and found that this error related to the number of elements contained in the sequence of the object type being returned by my WSDL.

Here is the solution I came up with for fixing the WSDL, but the problem remains that SOA appears to have a restriction on how my WSDL can be constructed. I wanted to verify if my findings are accurate.
pfarrellpfarrell
Does anyone know if there is a bug tracking environment or another venue I should submit this question to?  Basically, it centers around the Apex code generation failing on a WSDL I have (which can't be modified).  I want to find out if this is a failure of the code generator or a limitation of Salesforce SOA's WSDL support.
SuperfellSuperfell
Can you provide an example WSDL? I'm not really clear on where you're saying the multiple elements are.
BTW, WS-I BP1.1 says that you can only have a single part for doc-lit, but i'm not sure that's what you're saying.
pfarrellpfarrell
lol, I realized that this morning.  Probably would help to see what the WSDL looks like.

Our WSDL has a multi object output.  There is a result object, status, and requestId that are passed back as part of the output.  Here are the pertinent parts of the WSDL.  Let me know if you need to see the whole WSDL.

The problem element (CreateResponse) contains a sequence of three objects.  If I delete the RequestID and OverallStatus elements, from the WSDL, I can autogenerate Apex from the WSDL.  However, we have production code dependent on this WSDL, so we can't alter.
Code:
  <element name="CreateResponse">
    <complexType>
      <sequence>
        <element name="Results" type="tns:CreateResult" minOccurs="1" maxOccurs="unbounded" />
        <element name="RequestID" type="xsd:string" minOccurs="0" maxOccurs="1" />
        <element name="OverallStatus" type="xsd:string" minOccurs="1" maxOccurs="1" />
      </sequence>
    </complexType>
  </element>

  <message name="createResponse">
    <part element="tns:CreateResponse" name="parameters" />
  </message>

  <portType name="Soap">
    <operation name="Create">
      <documentation>Create objects</documentation>
      <input message="tns:createRequest" />
      <output message="tns:createResponse" />
    </operation>
  </portType>

 



cheenathcheenath
There is no out parameter in Apex. So apex method can only return one value.
Your Create method returns 3 elements and hence the error. You can wrap
the three elements into a complex type and return it. In this case your WSDL
will look like:

Code:
   <element name="CreateResponse">
      <complexType>
        <sequence>
          <element name="result" type="tns:CreateResponseInfo"/>
        </sequence>
      </complexType>
   </element>


    <complexType name="CreateResponseInfo">
      <sequence>
        <element name="Results" type="tns:CreateResult" minOccurs="1" maxOccurs=
"unbounded" />
        <element name="RequestID" type="xsd:string" minOccurs="0" maxOccurs="1"
/>
        <element name="OverallStatus" type="xsd:string" minOccurs="1" maxOccurs=
"1" />
      </sequence>
    </complexType>




HTHs,


 

pfarrellpfarrell
thanks cheenath,
I was hoping to be able to use my company's WSDL without alteration, but your method is not too bad and I have confirmed that your change allows Apex code generator to work correctly.  I'm just going to have to do some testing now :).