I have the following situation:
I exposed my Servoy Solution as a Webservice using Java. This all goes well.
Now have I defined a Class in Java which I fill in Servoy. Now as a result of the webCall this object must be passed back to the client.
But when I do that I get the following errormessage (isn't it the same object?):
- Code: Select all
'Fault is: com.data.SupplyResponse cannot be cast to com.data.SupplyResponse java.lang.ClassCastException: com.data.SupplyResponse cannot be cast to com.data.SupplyResponse'
The code, which both uses the same SupplyResponse Object:
Servoy
- Code: Select all
function GetSupply()
{
var data = Packages.com.data;
var response = data.SupplyResponse();
response .sellerParty = "A & B";
response .product= "C";
return response;
}
Java Headless Client.
- Code: Select all
public SupplyResponse ExecuteMethod(MessageContext mc, String solutionName, String formName, String methodName, Object[] parameters)
{
SupplyResponse returnObject = null;
HttpServletRequest request = ((HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST));
HttpSession session = ((HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
if(session == null)
throw new WebServiceException("No session available in the webservice context");
if(request == null)
throw new WebServiceException("Request is null");
ISessionBean servoy_hc = (ISessionBean) session.getAttribute("servoy");
try
{
if(servoy_hc == null)
{
//Aanmaken van de Headless client session.
servoy_hc = HeadlessClientFactory.createSessionBean(request,solutionName,null,null);
session.setAttribute("servoy", servoy_hc);
}
boolean ok = servoy_hc.setMainForm(formName);
if(!ok)
throw new WebServiceException("Error: Cannot work on required form: " + solutionName);
//Here it goes wrong
returnObject = (SupplyResponse) (servoy_hc.executeMethod(null, methodName, parameters ));
}
catch(Exception ex)
{
throw new WebServiceException("1: Fault is: " + ex.getMessage() + " " + ex.toString() );
}
finally
{
session.setAttribute("servoy",null);
}
return returnObject;
}
What can I be doing wrong, or is there a better solution to achieve this.