views:

33

answers:

2

I have an issue when I try to retrieve info through a webmethod. I am using a proxy to call a web service, in that proxy I have an operation which returns data using 'out' parameters.

The server executes the operation succesfully, giving back the parameters properly instanced (I also have checked the soap return message using a traffic analyzer and is ok), but when I ask for those parameters to the proxy, I only obtain null values.

Here is some code info:

//This is the call to the web service using the proxy (t is the proxy and get_capabilities is the webmethod)

public trf_capabilities get_capabilities() {
            trf_capabilities trfcap = new trf_capabilities();                
            trfcap.protocol_list= t.get_capabilities(0, out trfcap.pause, out trfcap.maxfiles, out trfcap.maxsize, out trfcap.encrypt, out trfcap.authenticate, out trfcap.integritycheck, out  trfcap.hashtype, out  trfcap.multipath, out  trfcap.profile_list);            
            return trfcap;
        }

//This is the webMethod definition

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("iTransfer-get_capabilities",/*RequestElementName="elementoVacio_",*/ RequestNamespace="", ResponseElementName="trf_capabilitiesPar", ResponseNamespace="", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("protocol_list", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public protocolType[] get_capabilities([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int vacio, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out bool pause, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out uint maxfiles, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out uint maxsize, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out bool encrypt, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out bool authenticate, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out bool integritycheck, [System.Xml.Serialization.XmlElementAttribute("hash_type", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out hash_typeType[] hash_type, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out bool multipath, [System.Xml.Serialization.XmlElementAttribute("profile_list", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out profile_listType[] profile_list) {
            object[] results = this.Invoke("get_capabilities", new object[] {
                        vacio});
            pause = ((bool)(results[1]));
            maxfiles = ((uint)(results[2]));
            maxsize = ((uint)(results[3]));
            encrypt = ((bool)(results[4]));
            authenticate = ((bool)(results[5]));
            integritycheck = ((bool)(results[6]));
            hash_type = ((hash_typeType[])(results[7]));
            multipath = ((bool)(results[8]));
            profile_list = ((profile_listType[])(results[9]));
            return ((protocolType[])(results[0]));
        }

As you can see, I am using the 'out' token in both call and handler method, but it seems is not enough to get the correct behaviour.

And finally, here is the SOAP message intercepted with the traffic analyzer:

Content-Type: text/xml; charset=UTF-8
Server: SOAPStandaloneServer
Content-Length: 584
Connection: close

<E:Envelope xmlns:E="http://schemas.xmlsoap.org/soap/envelope/" xmlns:A="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.w3.org/2001/XMLSchema"&gt;&lt;E:Body&gt;&lt;ns1:get_capabilitiesResponse xmlns:ns1=""><ns1:pause>true</ns1:pause><ns1:maxfiles>5</ns1:maxfiles><ns1:maxsize>0</ns1:maxsize><ns1:encrypt>true</ns1:encrypt><ns1:authenticate>true</ns1:authenticate><ns1:integritycheck>true</ns1:integritycheck><ns1:multipath>true</ns1:multipath></ns1:get_capabilitiesResponse></E:Body></E:Envelope>

Any ideas?

+1  A: 

I think you're on the right track with [decoration] and serializing the answers. the arrays in there seem a bit tricky, do you have serialization routines for the elements in them?

Then again, having that amount of output parameters seems kind of overwhelming. I would probably have created a "ServiceResponse" struct and added all the params as properties in it.

EDIT: Next step, if the response seems ok but the proxy has problems deserializing it, I would suggest (of course) delving deeper into the proxy. Is the proxy generated or have you written it manually? Try to step through it and see what it tries to do with the parameters it's been given. Often I hack about with web services till my eyes bleed, only to discover that the deserialization spec was obsolete.

Streamcap
Thank you for your comment. I really agree with your suggest, but I am afraid there is no much to do with the data structure of the proxy. They gave me that in such way, so I have to deal with it as good as I can.Since I have tested succesfully the 'out' modifiers with another web service (written completely in C#), I think it has to be something related with standars and serialization. BTW: the web service server is written in C++.
Francisco
A: 

I found something interesting about all of this. I have been checking the headers of the two types of web methods I have (the one written in C++ I have to use and the test one I developed in C#). I realised that, for out parameters, .NET add some kind of wrapping. Here comes the msdn explanation:

The XML portion of the SOAP response encapsulates the out parameters for the Web service method, including the result inside an element. The name of the encapsulating element, by default, is the name of the Web service method with Response appended to it.

Here is the link

It seems you have to use that wrapper in order to get 'out' reference parameters working.

Francisco
No luck. Both headers have the same [decoration] except some Namespaces requeriments that do not think are causing the problems...deadend..
Francisco
Well, I have made it work by using comments at "ResponseElementName"
Francisco