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:
[code name="LocationAlgorithm.java"]
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;
}
}
[/code]
The simple webservice:
[code name="WebServiceImpl.java"]
package lbs.webservice.bundle;
public class WebServiceImpl implements WebService {
public LocationAlgorithm getLocationAlgorithm() {
return new LocationAlgorithm(0, 0, "");
}
}
[/code]
Axis needs to know how to handle the object, so I add the following to
the config file server-config.wsdd:
[code name="server-config.wsdd"]
<beanMapping qname="ns:LocationAlgorithm"
xmlns:ns="http://localhost:9090/axis/services/LBSWebService"
languageSpecificType="java:lbs.webservice.bundle.LocationAlgorithm"/>
[/code]
When I load the WebService, a wsdl is generated (full wsdl is found
here: http://users.atlantis.ugent.be/dvrslype/LBSWebService.xml).
In the wsdl it is clear the Axis server recognizes the LocationAlgorithm
type:
[code "LBSWebService.wsdl"]
<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>
[/code]
But the return type of getLocationAlgorithm is set to "xsd:anyType"
instead of LocationAlgorithm. :S
[code "LBSWebService.wsdl"]
<wsdl:message name="getLocationAlgorithmResponse">
<wsdl:part name="getLocationAlgorithmReturn" type="xsd:anyType"/>
</wsdl:message>
[/code]
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