I'm having a hard time with a SOAP webservice client.
I've deployed my webservice locally with a crossdomain.xml file
allowing connections from everywhere.
I've tested my webservice with a SOAP tester (SOAP Client on the Mac),
and it works great: it actually returns something.
Then I've imported the WSDL file into Flex Builder 3 in order to
generate stubs and everything.
The code compiles, the webservice is called, the response comes back
but the lastResult is always null.
I've debugged the whole thing until the point where the result is processed:
private function processResult(result:Object,wrappedData:Object):void
{
var token:AsyncToken = wrappedData.returnToken;
var currentOperation:WSDLOperation = wrappedData.operation;
var decoder:SOAPDecoder = new SOAPDecoder();
decoder.resultFormat="object";
decoder.ignoreWhitespace = true;
decoder.makeObjectsBindable=true;
decoder.wsdlOperation = currentOperation;
decoder.schemaManager = currentOperation.schemaManager;
var body:Object = result.message.body;
var stringResult:String = String(body);
if(stringResult == null || stringResult == "")
return;
var soapResult:SOAPResult =
decoder.decodeResponse(result.message.body);
if(soapResult.isFault)
{
var faults:Array = soapResult.result as Array;
for each (var soapFault:Fault in faults)
{
var soapFaultEvent:FaultEvent =
FaultEvent.createEvent(soapFault,token,null);
token.dispatchEvent(soapFaultEvent);
}
} else {
result =
decoder.decodeResponse(result.message.body).result;
if(result is ArrayCollection)
{
//shoud upcast to specific type here
var arrayTypedClass:Class =
SchemaTypeRegistry.getClass(currentOperation.outputMessage.parts[0].type);
result = new arrayTypedClass(result.source);
}
var event:ResultEvent =
ResultEvent.createEvent(result,token,null)
token.dispatchEvent(event);
}
}
And even though stringResult contains a response with data, that
corresponds to what I get in SOAP client, the result of the call to
decoder.decodeResponse(result.message.body) is always null.
So obviously something is wrong with SOAPDecoder, but I can't find any
source for it.
By the way, here is the content of stringResult that is decoded:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<soapenv:Header>
<wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
getAllUsers
</wsa:Action>
<wsa:ReplyTo xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<wsa:Address>
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
</wsa:Address>
</wsa:ReplyTo>
<wsa:From xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<wsa:Address>
http://localhost:8080/basement-ws/services/UserManagementService
</wsa:Address>
</wsa:From>
<wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
5F233385193DA1559D11940612843298
</wsa:MessageID>
</soapenv:Header>
<soapenv:Body>
<res:getAllUsersResponse xmlns:res="http://soapenc/">
<arg0 xmlns="">
<fullName xmlns="">SÃ(c)bastien Arbogast</fullName>
<id xmlns="">1</id>
<username xmlns="">sarbogast</username>
</arg0>
</res:getAllUsersResponse>
</soapenv:Body>
</soapenv:Envelope>
--
Sébastien Arbogast
http://www.sebastien-arbogast.com