Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Webservice returning null object to a .net client

Can any one figure out my problem is...

I'm calling a webmethod of a Java Webservice (Axis 1.4) from a .Net client. That method returns a Map object, and if i call it from an Axis client works fine, but in my c# code it´s always null.

That's the WSDL:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:http.service.enlaces.portlet.ext.com" xmlns:intf="urn:http.service.enlaces.portlet.ext.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://model.enlaces.portlet.ext.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:http.service.enlaces.portlet.ext.com">

<wsdl:types>

<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.apache.org/xml-soap">
<import namespace="urn:http.service.enlaces.portlet.ext.com"/>
<import namespace="http://model.enlaces.portlet.ext.com"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="mapItem">
   <sequence>
 <element name="key" nillable="true" type="xsd:anyType"/>
 <element name="value" nillable="true" type="xsd:anyType"/>
   </sequence>
</complexType>
<complexType name="Map">
   <sequence>
   <element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>
   </sequence>
</complexType>   
</schema>
 </wsdl:types>

<wsdl:message name="getFoldersAndBookmarksRequest" />
<wsdl:message name="getFoldersAndBookmarksResponse">
    <wsdl:part name="getFoldersAndBookmarksReturn" type="apachesoap:Map" />
</wsdl:message>

<wsdl:portType name="BookmarksEntryServiceSoap">
<wsdl:operation name="getFoldersAndBookmarks">
      <wsdl:input name="getFoldersAndBookmarksRequest"  message="intf:getFoldersAndBookmarksRequest" />
      <wsdl:output name="getFoldersAndBookmarksResponse" message="intf:getFoldersAndBookmarksResponse" />
    </wsdl:operation>
  </wsdl:portType>

<wsdl:binding name="Portlet_Bookmarks_BookmarksEntryServiceSoapBinding" type="intf:BookmarksEntryServiceSoap">
    <wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
  <wsdl:operation name="getFoldersAndBookmarks">
      <wsdlsoap:operation soapAction="" />
      <wsdl:input name="getFoldersAndBookmarksRequest">
        <wsdlsoap:body use="encoded" namespace="urn:http.service.enlaces.portlet.ext.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:input>
      <wsdl:output name="getFoldersAndBookmarksResponse">
        <wsdlsoap:body use="encoded" namespace="urn:http.service.enlaces.portlet.ext.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

and my c# auto-generated code:

[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="urn:http.service.enlaces.portlet.ext.com", ResponseNamespace="urn:http.service.enlaces.portlet.ext.com")]
[return: System.Xml.Serialization.SoapElementAttribute("getFoldersAndBookmarksReturn")]
public Map getFoldersAndBookmarks() {
    object[] results = this.Invoke("getFoldersAndBookmarks", new object[0]);
    return ((Map)(results[0]));
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="http://xml.apache.org/xml-soap")]
public partial class Map {

    private mapItem[] itemField;

    /// <comentarios/>
    public mapItem[] item {
        get {
            return this.itemField;
        }
        set {
            this.itemField = value;
        }
    }
}

I,ve seen everywhere unfortunately, i don't find the solution. Please, there are anyone what knows it?

like image 625
ChkDuke Avatar asked Nov 05 '22 11:11

ChkDuke


2 Answers

I've faced the same problem a while ago. This happens when you try to get an array of elements through an axis webservice with a .net client.

The problem is "name=item" part of this line :

<element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>

Try changing in that particular line "item" to "mapItem". Try one of these :

<element maxOccurs="unbounded" minOccurs="0" name="mapItem" type="apachesoap:mapItem"/>

or

<element maxOccurs="unbounded" minOccurs="0" name="key" type="apachesoap:mapItem"/>

or

<element maxOccurs="unbounded" minOccurs="0" name="value" type="apachesoap:mapItem"/>
like image 108
UmutKa Avatar answered Nov 12 '22 17:11

UmutKa


So it very late to help you but I recently was running into the same problem.

Firstly I am using Eclipse to create a web service. The problem for me was that the wsdd generated was using the 'document/literal(wrapped)' style. Changing that to 'RPC' fixed the issue. No more nulls.

So maybe if you change your encoding to RPC that might fix your issue too.

like image 25
Furqan Tariq Avatar answered Nov 12 '22 15:11

Furqan Tariq