In a previous post I explained how to list available operations provided by a WebService, parsing the WSDL document using some undocumented classes of the Flex 3 and 4 SDKs.
This time I want to give you some suggestions about the next step: listing parameters of every operation.
NB: most of the classes in the package mx.rpc.wsdl have the tag [ExcludeClass] so they could change with an SDK update or they can be not stable. Flex Builder intellisense will not work for these classes, so you have to import them manually.
Note that I'm testing this code using a WSDL from a Axis2 WebService, it may not work on WSDL with a different structure or it may need some tweaks.
<mx:Script>
<![CDATA[
import mx.rpc.soap.LoadEvent;
import mx.rpc.wsdl.WSDLMessagePart;
import mx.rpc.wsdl.WSDLOperation;
import mx.rpc.xml.Schema;
protected function loadHandler(event:LoadEvent):void
{
if(event.wsdl) {
for each(var op:WSDLOperation in event.wsdl.getPort().binding.portType.operations()) {
var param:WSDLMessagePart = op.inputMessage.getPart("parameters");
if(param) {
var schema:Schema = event.wsdl.schemaManager.getResourcesForURI(param.element.uri)[0] as Schema;
var element:Object = schema.getNamedDefinition(new QName(schema.schemaConstants.xsdURI,param.element.localName),schema.schemaConstants.elementTypeQName);
trace(element.definition, element.schema);
}
}
}
}
]]>
</mx:Script>
This small script, based on the code of the previous post, analyze the inputMessage of the WSDLOperation. If there is a WSDLMessagePart with name "parameters", it looks for the related Schema and then it searches the definition of the element of the WSDLMessagePart. This definition is just the XML of the complexType of the parameter, then you have to write your custom logic to use it. Some WSDL may non have the "part" node, instead there is the name of the element, you have to slightly modify the code above.
This is just a sketch and not a ready-to-use solution but it can point you in the right direction.