Web Hosting Talk







View Full Version : [AXIS SOAP] Return Custom Type Problem


dvrslype
07-26-2005, 10:29 AM
Hello,

I'm writing a WebService using the Axis bundle for OSGi (this is the same as a stand alone Axis server but running on the OSGi platform).
I'm trying to return a custom object (LocationAlgorithm) when the client does a request for it. LocationAlgorithm holds 2 integers and a String,
a default constructor and getters and setters for the attributes (so it's a JavaBean). Here is the trivial code:




package lbs.webservice.bundle;

public class LocationAlgorithm
{
private int numberOfMeasurements, intervalBetweenMeasurements;

private String measurementType;

public LocationAlgorithm() {
numberOfMeasurements = 0;
intervalBetweenMeasurements = 0;
measurementType = null;
}

public int getIntervalBetweenMeasurements() {
return intervalBetweenMeasurements;
}

public void setIntervalBetweenMeasurements(int intervalBetweenMeasurements) {
this.intervalBetweenMeasurements = intervalBetweenMeasurements;
}

public String getMeasurementType() {
return measurementType;
}

public void setMeasurementType(String measurementType) {
this.measurementType = measurementType;
}

public int getNumberOfMeasurements() {
return numberOfMeasurements;
}

public void setNumberOfMeasurements(int numberOfMeasurements) {
this.numberOfMeasurements = numberOfMeasurements;
}
}



The simple webservice:



package lbs.webservice.bundle;

public class WebServiceImpl implements WebService {

public LocationAlgorithm getLocationAlgorithm() {
return new LocationAlgorithm(0, 0, "");
}
}



Axis needs to know how to handle the object, so I add the following to the config file server-config.wsdd:



<beanMapping qname="ns:LocationAlgorithm" xmlns:ns="LBSWebService"
languageSpecificType="java:lbs.webservice.bundle.LocationAlgorithm"/>



When I load the WebService, a wsdl is generate.
In the wsdl it is clear the Axis server recognizes the LocationAlgorithm type:



<complexType name="LocationAlgorithm">
<sequence>
<element name="intervalBetweenMeasurements" type="xsd:int"/>
<element name="measurementType" nillable="true" type="xsd:string"/>
<element name="numberOfMeasurements" type="xsd:int"/>
</sequence>
</complexType>



But the return type of getLocationAlgorithm is set to "xsd:anyType" instead of LocationAlgorithm. :S



<wsdl:message name="getLocationAlgorithmResponse">
<wsdl:part name="getLocationAlgorithmReturn" type="xsd:anyType"/>
</wsdl:message>




So when I try calling the method, I get an "Unexpected end of file from server" - error.

Long story, but does anybody know how to fix this?

thx in advance,

dvrslype