Hi!
I'm creating the following WebService on the dmServer:
The WebService is not working properly and it's returning this has a response:Code:package insertPointWS.ws; //Libraries for Spring-WS part import insertPointWS.Positions; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.Namespace; import org.jdom.xpath.XPath; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ws.server.endpoint.AbstractJDomPayloadEndpoint; public class InsertPointEndpoint extends AbstractJDomPayloadEndpoint implements InitializingBean { private Namespace namespace; private XPath latXPath; private XPath lonXPath; private XPath fleetidXPath; @Autowired private Positions positions; private float lat; private float lon; private long fleetid; protected Element invokeInternal(Element element) throws Exception { String response = "OKEY"; //Extract Position from Request extractPositionFromRequest(element); //If code_error OKEY if(!CheckErrorCondition()){ //Insert or Update position into DB using business logic boolean ok = positions.insertPosition(lat, lon, fleetid); if(!ok) response="ERROR"; } else{ response="ERROR"; } //Create and return response return createResponse(response); } private void extractPositionFromRequest(Element element) throws JDOMException { //Get information from XML Request //if Latitude/Longitude is NULL assign a value Out of Bound this.lat = Float.parseFloat(latXPath.valueOf(element).length()==0?"999":latXPath.valueOf(element)); this.lon = Float.parseFloat(lonXPath.valueOf(element).length()==0?"999":lonXPath.valueOf(element)); this.fleetid = Long.parseLong(fleetidXPath.valueOf(element).length()==0?"999":fleetidXPath.valueOf(element)); } public void afterPropertiesSet() throws Exception { namespace = Namespace.getNamespace("ip", "http://myflit.com/ip"); latXPath = XPath.newInstance("//ip:Lat"); latXPath.addNamespace(namespace); lonXPath = XPath.newInstance("//ip:Lon"); lonXPath.addNamespace(namespace); fleetidXPath = XPath.newInstance("//ip:FleetId"); fleetidXPath.addNamespace(namespace); } private Element createResponse(String response) { Element responseElement = new Element("InsertPointResponse", namespace); //Creates XML response responseElement.addContent(new Element("Response", namespace).setText(response)); return responseElement; } private boolean CheckErrorCondition(){ boolean error = false; //Latitude or Longitude Out of Bounds if(this.lat>90||this.lat<-90||this.lon>180||this.lon<-180) error=true; return error; } }
The point is that when commenting this line:Code:<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring xml:lang="en">java.lang.NullPointerException</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
positions.insertPosition(lat, lon, fleetid);
in the web service code, it works correctly.
So I can guess there is a problem when using this service (exported to the OSGi service register by the bundle insertPointWS.jpa) with my WebServices.
Is there any incompatibility between WebServices and this OSGi service register? What am I doing wrong?
Thank you very much!
Best regards,
Victor


