You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by jpsabadini <jp...@gmail.com> on 2007/03/08 14:18:16 UTC
Re: [Axis2] AxisFault: please help!!
Thanks for your anwser!!!
Here is the service class:
/**
* MobileServiceSkeleton.java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: SNAPSHOT Feb 19, 2007 (03:30:55 GMT+00:00)
*/
package com.vmon.ws.mobile;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.ejb.CreateException;
import javax.mail.util.ByteArrayDataSource;
import javax.naming.NamingException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.SessionContext;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.Logger;
import com.gauss.orm.exceptions.InfrastructureException;
import com.gauss.vmon.ws.mobile.xsd.CatalogDataType;
import com.gauss.vmon.ws.mobile.xsd.GetCatalog;
import com.gauss.vmon.ws.mobile.xsd.GetCatalogResponse;
import com.gauss.vmon.ws.mobile.xsd.GetImage;
import com.gauss.vmon.ws.mobile.xsd.GetImageResponse;
import com.gauss.vmon.ws.mobile.xsd.Login;
import com.gauss.vmon.ws.mobile.xsd.LoginResponse;
import com.gauss.vmon.ws.util.Constants;
import com.gauss.vmon.orm.data.ObjectCatalogDTO;
import com.gauss.vmon.orm.data.UserDTO;
import com.gauss.vmon.orm.exceptions.UserNotFoundException;
import com.gauss.vmon.ols.data.SnapshotDTO;
import com.gauss.vmon.ols.service.ObjectsLibraryServiceMBean;
import com.gauss.vmon.ols.util.ObjectsLibraryServiceUtil;
import com.gauss.vmon.bl.exceptions.UserNotEnabledException;
import com.gauss.vmon.bl.exceptions.UserWrongPasswordException;
import com.gauss.vmon.bl.interfaces.ObjectServiceEJBLocal;
import com.gauss.vmon.bl.interfaces.ObjectServiceEJBUtil;
import com.gauss.vmon.bl.interfaces.UserServiceEJBLocal;
import com.gauss.vmon.bl.interfaces.UserServiceEJBUtil;
import com.gauss.vmon.bl.interfaces.ViewerServiceEJBLocal;
import com.gauss.vmon.bl.interfaces.ViewerServiceEJBUtil;
import com.gauss.vmon.web.util.MD5;
/**
* MobileServiceSkeleton java skeleton for the axisService
*/
public class MobileServiceSkeleton implements MobileServiceSkeletonInterface
{
private static Logger log = Logger.getLogger(Constants.LOG4J_CATEGORY);
protected String className =
this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".")
+ 1);
/*
* Propiedades de session
*/
private Integer usrId = null;
private Integer entId = null;
private Boolean isLogged = Boolean.FALSE;
/*
* Propiedades de session para el Snapshot
*/
private Boolean isConnected = Boolean.FALSE;
private Integer objId = null;
private SnapshotDTO snapshotData = null;
private HttpClient httpClient = new HttpClient();
/**
* Auto generated method signature
* @param login
*/
public LoginResponse login(Login login) {
final String methodName = className + "." + "login";
log.debug(methodName + ".Begin");
try {
SessionContext sessionContext = getSessionContext();
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
ServletContext servletContext = (ServletContext)
msgCtx.getProperty("transport.http.servletContext");
HttpServletRequest httpServletRequest = (HttpServletRequest)
msgCtx.getProperty("transport.http.servletRequest");
SessionContext sessionCtx = msgCtx.getSessionContext();
log.debug("ServiceGroupContextId: " +
msgCtx.getServiceGroupContextId());
log.debug("SessionId: " + msgCtx.getProperty("SessionId"));
log.debug("Cookie: " + msgCtx.getProperty("Cookie"));
LoginResponse loginResponse = new LoginResponse();
loginResponse.setStatus(0);
log.debug("Logged: " + isLogged);
if (isLogged) {
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_ALREADY_LOGGED);
return loginResponse;
}
UserServiceEJBLocal userService = null;
try {
userService = UserServiceEJBUtil.getLocalHome().create();
}
catch (CreateException e2) {
log.error("Exception in AuthenticationService: " + e2.getMessage());
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_EXCEPTION);
return loginResponse;
}
catch (NamingException e2) {
log.error("Exception in AuthenticationService: " + e2.getMessage());
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_EXCEPTION);
return loginResponse;
}
UserDTO userData = new UserDTO();
this.usrId = null;
this.entId = null;
this.isLogged = Boolean.FALSE;
this.isConnected = Boolean.FALSE;
this.objId = null;
this.snapshotData = null;
sessionContext.setProperty(Constants.WS_SESSION_IS_LOGGED, isLogged);
try {
String md5HashPassword = MD5.createMD5(login.getPassword());
userData.setLogonId(login.getUsername());
userData.setPassword(md5HashPassword);
userData = userService.authenticateUser(userData);
this.usrId = userData.getUsrId();
this.entId = userData.getEntId();
this.isLogged = Boolean.TRUE;
sessionContext.setProperty(Constants.WS_SESSION_IS_LOGGED,
isLogged);
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_OK);
}
catch (UserNotEnabledException e) {
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_USER_NOT_ENABLED);
}
catch (UserNotFoundException e) {
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_USER_NOT_FOUND);
}
catch (UserWrongPasswordException e) {
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_WRONG_PASSWORD);
}
catch (NoSuchAlgorithmException e) {
loginResponse.setStatus(Constants.WS_LOGIN_STATUS_EXCEPTION);
}
return loginResponse;
}
finally {
log.debug(methodName + ".End");
}
}
/**
* Auto generated method signature
* @param getCatalog
*/
public GetCatalogResponse getCatalog(GetCatalog getCatalog) {
final String methodName = className + "." + "getCatalog";
log.debug(methodName + ".Begin");
GetCatalogResponse response = new GetCatalogResponse();
ObjectServiceEJBLocal objectService = null;
try {
objectService = ObjectServiceEJBUtil.getLocalHome().create();
}
catch (CreateException e) {
log.error("Exception in " + methodName + ": " + e.getMessage());
return response;
}
catch (NamingException e) {
log.error("Exception in " + methodName + ": " + e.getMessage());
return response;
}
if (!this.isLogged) {
return response;
}
Collection coll = objectService.searchObjectsCatalogByUser(this.usrId);
for (Iterator iter = coll.iterator(); iter.hasNext();) {
ObjectCatalogDTO o = (ObjectCatalogDTO) iter.next();
CatalogDataType catalogData = new CatalogDataType();
catalogData.setObjId(o.getObjId());
catalogData.setObjType(o.getObjType());
catalogData.setName(o.getName());
response.addCatalogData(catalogData);
}
log.debug(methodName + ".End");
return response;
}
public GetImageResponse getImage(GetImage getImage) {
final String methodName = className + "." + "getImage";
log.debug(methodName + ".Begin");
SessionContext sessionContext = getSessionContext();
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
ServletContext servletContext = (ServletContext)
msgCtx.getProperty("transport.http.servletContext");
HttpServletRequest httpServletRequest = (HttpServletRequest)
msgCtx.getProperty("transport.http.servletRequest");
SessionContext sessionCtx = msgCtx.getSessionContext();
ObjectsLibraryServiceMBean olsMBean = null;
ViewerServiceEJBLocal viewerService = null;
try {
olsMBean = ObjectsLibraryServiceUtil.getMBean();
viewerService = ViewerServiceEJBUtil.getLocalHome().create();
}
catch (CreateException e) {
throw new InfrastructureException(methodName + ".Error finding
ObjectsLibraryService: " + e);
}
catch (NamingException e) {
throw new InfrastructureException(methodName + ".Error finding
ObjectsLibraryService: " + e);
}
GetImageResponse imageResponse = new GetImageResponse();
try {
if (!isConnected || getImage.getObjId() != this.objId) {
snapshotData = viewerService.getSnapshotURL(getImage.getObjId(),
getImage.getSize(), httpServletRequest.getRemoteAddr());
this.isConnected = Boolean.TRUE;
this.objId = getImage.getObjId();
HostConfiguration hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(snapshotData.getIp(), new
Integer(snapshotData.getHttpPort()).intValue());
httpClient.setHostConfiguration(hostConfiguration);
httpClient.getParams().setAuthenticationPreemptive(true);
UsernamePasswordCredentials credentials1 = new
UsernamePasswordCredentials(snapshotData.getUsername(), snapshotData
.getPassword());
AuthScope authScope = new
AuthScope(httpClient.getHostConfiguration().getHost(),
httpClient.getHostConfiguration()
.getPort(), AuthScope.ANY_REALM);
HttpState httpState = httpClient.getState();
httpState.setCredentials(authScope, credentials1);
this.isConnected = Boolean.TRUE;
this.objId = getImage.getObjId();
}
GetMethod getMethod = new GetMethod(snapshotData.getUrl());
getMethod.setDoAuthentication(true);
int status = httpClient.executeMethod(getMethod);
byte[] binaryBytes = getMethod.getResponseBody();
String contentType =
getMethod.getResponseHeader("Content-Type").getValue();
ByteArrayDataSource dataSource = new ByteArrayDataSource(binaryBytes,
contentType);
DataHandler dataHandler = new DataHandler(dataSource);
getMethod.releaseConnection();
imageResponse = new GetImageResponse();
imageResponse.setImage(dataHandler);
}
catch (IOException e) {
imageResponse.setImage(null);
}
finally {
}
log.debug(methodName + ".End");
return imageResponse;
}
private SessionContext getSessionContext() {
MessageContext messageContext =
MessageContext.getCurrentMessageContext();
if (messageContext == null) {
return null;
}
SessionContext sessionContext = messageContext.getSessionContext();
return sessionContext;
}
}
And here is the service.xml:
<serviceGroup>
<service
name="MobileService"
scope="transportsession">
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/2006/01/wsdl/in-out"
class="com.gauss.vmon.ws.mobile.MobileServiceMessageReceiverInOut"
/>
</messageReceivers>
<parameter
locked="false"
name="ServiceClass">
com.gauss.vmon.ws.mobile.MobileServiceSkeleton
</parameter>
<operation
name="login"
mep="http://www.w3.org/2006/01/wsdl/in-out">
<actionMapping>urn:login</actionMapping>
<outputActionMapping>
http://www.vmonitoring.com/MobileService/MobileServicePortType/loginResponse
</outputActionMapping>
</operation>
<operation
name="getCatalog"
mep="http://www.w3.org/2006/01/wsdl/in-out">
<actionMapping>urn:getCatalog</actionMapping>
<outputActionMapping>
http://www.vmonitoring.com/MobileService/MobileServicePortType/getCatalogResponse
</outputActionMapping>
</operation>
<operation
name="getImage"
mep="http://www.w3.org/2006/01/wsdl/in-out">
<actionMapping>urn:getImage</actionMapping>
<outputActionMapping>
http://www.vmonitoring.com/MobileService/MobileServicePortType/getImageResponse
</outputActionMapping>
</operation>
</service>
</serviceGroup>
and last I have de MobileService.wsdl:
<wsdl:definitions
xmlns:ns="http://www.vmonitoring.com/MobileService/xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:tns="http://www.vmonitoring.com/MobileService/"
xmlns:wsa="http://www.w3.org/2005/08/addressing/"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
targetNamespace="http://www.vmonitoring.com/MobileService/">
<wsdl:types>
<xsd:schema
attributeFormDefault="unqualified"
elementFormDefault="unqualified"
targetNamespace="http://www.vmonitoring.com/MobileService/xsd">
<xsd:element name="login">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="username"
type="xsd:string" />
<xsd:element
name="password"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="loginResponse">
<xsd:complexType>
<xsd:sequence
minOccurs="1"
maxOccurs="1">
<xsd:element
name="status"
type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getCatalog">
<xsd:complexType>
<xsd:sequence
minOccurs="1"
maxOccurs="1">
<xsd:element
name="usrId"
type="xsd:int"
minOccurs="1"
maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getCatalogResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
minOccurs="0"
maxOccurs="unbounded"
name="CatalogData"
type="ns:CatalogDataType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="CatalogDataType">
<xsd:sequence>
<xsd:element
name="objId"
type="xsd:int" />
<xsd:element
name="objType"
type="xsd:string">
</xsd:element>
<xsd:element
name="name"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="formatType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="jpg"></xsd:enumeration>
<xsd:enumeration value="png"></xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="getImage">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="objId"
type="xsd:int">
</xsd:element>
<xsd:element
name="size"
type="xsd:string">
</xsd:element>
<xsd:element
name="format"
type="ns:formatType">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getImageResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="image"
type="xsd:base64Binary">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getCatalogRequest">
<wsdl:part
name="parameters"
element="ns:getCatalog" />
</wsdl:message>
<wsdl:message name="getCatalogResponse">
<wsdl:part
name="parameters"
element="ns:getCatalogResponse" />
</wsdl:message>
<wsdl:message name="loginRequest">
<wsdl:part
name="parameters"
element="ns:login" />
</wsdl:message>
<wsdl:message name="loginResponse">
<wsdl:part
name="parameters"
element="ns:loginResponse" />
</wsdl:message>
<wsdl:message name="getImageRequest">
<wsdl:part
name="parameters"
element="ns:getImage">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getImageResponse">
<wsdl:part
name="parameters"
element="ns:getImageResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="MobileServicePortType">
<wsdl:operation name="login">
<wsdl:input message="tns:loginRequest" />
<wsdl:output message="tns:loginResponse" />
</wsdl:operation>
<wsdl:operation name="getCatalog">
<wsdl:input message="tns:getCatalogRequest"></wsdl:input>
<wsdl:output message="tns:getCatalogResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="getImage">
<wsdl:input message="tns:getImageRequest"></wsdl:input>
<wsdl:output message="tns:getImageResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding
name="MobileServiceSOAP"
type="tns:MobileServicePortType" >
<soap:binding
style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="login">
<soap:operation soapAction="urn:login" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getCatalog">
<soap:operation soapAction="urn:getCatalog" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getImage">
<soap:operation soapAction="urn:getImage" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MobileService">
<wsdl:port
binding="tns:MobileServiceSOAP"
name="MobileServiceSOAP">
<soap:address
location="http://www.vmonitoring.com/services/MobileService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
thanks!
Thilina Gunarathne wrote:
>
> Are you also in controll of the service too...
> If so if you don't mind please post the services.xml and the service
> class.. Also please check the method names of your service class...
>
> Thanks,
> Thilina
>
> On 3/8/07, jpsabadini <jp...@gmail.com> wrote:
>>
>> Hi all,
>> I´m getting a org.apache.axis2.AxisFault: ServiceClass does not implement
>> required method of the form OMElement login(OMElement e) when I´m
>> executing
>> a test client that consumes a WS.
>>
>> The client is:
>>
>> package com.vmon.ws.mobile;
>>
>> import java.rmi.RemoteException;
>> import org.apache.log4j.Logger;
>> import com.gauss.vmon.ws.mobile.xsd.CatalogDataType;
>> import com.gauss.vmon.ws.mobile.xsd.GetCatalog;
>> import com.gauss.vmon.ws.mobile.xsd.GetCatalogResponse;
>> import com.gauss.vmon.ws.mobile.xsd.Login;
>> import com.gauss.vmon.ws.mobile.xsd.LoginResponse;
>>
>> public class MobileServiceClient {
>>
>> private static Logger log =
>> Logger.getLogger(MobileServiceClient.class);
>> protected String className =
>> this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".")
>> + 1);
>>
>> public static void main(String[] args)
>> throws Exception {
>>
>> try {
>>
>> MobileServiceStub mobileStub = new
>> MobileServiceStub("http://alpha.vmonitoring.com/services/MobileService");
>> mobileStub._getServiceClient().getOptions().setManageSession(true);
>>
>> Login login = new Login();
>> login.setUsername("asd");
>> login.setPassword("asd");
>>
>> LoginResponse loginResponse;
>>
>> loginResponse = mobileStub.login(login);
>> System.out.println("1: " + loginResponse.getStatus());
>>
>> loginResponse = mobileStub.login(login);
>> System.out.println("2: " + loginResponse.getStatus());
>>
>> GetCatalog getCatalog = new GetCatalog();
>> getCatalog.setUsrId(0);
>>
>> GetCatalogResponse catalogResponse =
>> mobileStub.getCatalog(getCatalog);
>> CatalogDataType[] cameras = catalogResponse.getCatalogData();
>>
>> for (int i = 0; i < cameras.length; i++) {
>> System.out.println(cameras[i].getObjId() + ", " +
>> cameras[i].getName());
>> }
>> System.out.println("FIN");
>> }
>> catch (RemoteException e) {
>> e.printStackTrace();
>> }
>> finally {
>> }
>> }
>> }
>>
>> The exception occurs at loginResponse = mobileStub.login(login);
>>
>> I don´t know what the exception is!! Any clue?
>>
>> Thanks in advance.
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/AxisFault%3A-please-help%21%21-tf3364506.html#a9360765
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
> --
> Thilina Gunarathne
> WSO2, Inc.; http://www.wso2.com/
> Home page: http://webservices.apache.org/~thilina/
> Blog: http://thilinag.blogspot.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/AxisFault%3A-please-help%21%21-tf3364506.html#a9374150
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org