6

How do I expose an Apex method as a WebService that accepts the following input:

<soap:Body>
   <request>
       <myelement type="something">
        ...
       </myelement>
   </request>
</soap:Body>

The problem is that I am able to create the "type" as an element - a child under "myelement" like this:

<myelement>
   <type>something</type>
</myelement>

But I am not able to make the "type" as an attribute to "myelement". When we consume webservices in salesforce, the stubs have the following properties to make allow attributes :

private String[] type_x_att_info = new String[]{'type'};

But when we try to publish a WebService, how do we do that ?

1 Answer 1

2

I suspect that answer is that you can't currently.

The only way to mark a member of a parameter or return type class is with the webservice keyword.

As you found, this results in an element rather than an attribute of the in the generated WSDL complexType.

The most relevant documentation I could find was Considerations for Using the WebService Keyword.

You must use the webService keyword with any member variables that you want to expose as part of a Web service. You should not mark these member variables as static.

There is no mention of how you could indicate that the member should be an attribute rather than an element.

You could raise this as an ideaExchange idea and link to it from this question/answer.

0

You must log in to answer this question.

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