Try the classes i have appended.
don't forget to change the url in SoapUserServiceLocater.java
I used your wsdd to deploy.


-----Urspr�ngliche Nachricht-----
Von: Marco Rossi <[EMAIL PROTECTED]>
An: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Datum: Donnerstag, 21. Oktober 2004 11:56
Betreff: Re: return null Object


It doesn't work.
This is the source:
public class SoapUser {
    public SimpleUser findNameByPK(int id){
        SimpleUser simpleUser = new SimpleUser();

        UserService userService = new UserService();
        WeseUser user = userService.getByPrimaryKey(1);

        simpleUser.setId(user.getUserId().intValue());
        simpleUser.setNome(user.getUserNome());


        return simpleUser;

    }
}

with SimpleUser like this:
public class SimpleUser implements Serializable{
    public SimpleUser()
    {
    }

    public int id;
    /**
     * @return Returns the id.
     */
    public int getId() {
        return id;
    }
    /**
     * @param id The id to set.
     */
    public void setId(int id) {
        this.id = id;
    }
    /**
     * @return Returns the nome.
     */
    public String getNome() {
        return nome;
    }
    /**
     * @param nome The nome to set.
     */
    public void setNome(String nome) {
        this.nome = nome;
    }
    public String nome;
}


here is the deploy.wsdd:
<!-- Use this file to deploy some handlers/chains and services      -->
<!-- Two ways to do this:                                           -->
<!--   java org.apache.axis.client.AdminClient deploy.wsdd          -->
<!--      after the axis server is running                          -->
<!-- or                                                             -->
<!--   java org.apache.axis.utils.Admin client|server deploy.wsdd   -->
<!--      from the same directory that the Axis engine runs         -->

<deployment
    xmlns="http://xml.apache.org/axis/wsdd/";
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>

  <!-- Services from SoapUserService WSDL service -->

  <service name="security" provider="java:RPC" style="rpc" use="encoded">
      <parameter name="wsdlTargetNamespace" value="urn:siag.security.soap"/>
      <parameter name="wsdlServiceElement" value="SoapUserService"/>
      <parameter name="wsdlServicePort" value="security"/>
      <parameter name="className"
value="siag.security.soap.ws.SecuritySoapBindingImpl"/>
      <parameter name="wsdlPortType" value="SoapUser"/>
      <operation name="findNameByPK" qname="operNS:findNameByPK"
xmlns:operNS="urn:siag.security.soap" returnQName="findNameByPKReturn"
returnType="rtns:SimpleUser" xmlns:rtns="urn:siag.security.soap" >
        <parameter name="id" type="tns:int"
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
      </operation>
      <parameter name="allowedMethods" value="findNameByPK"/>
      <parameter name="scope" value="Session"/>

      <typeMapping
        xmlns:ns="urn:siag.security.soap"
        qname="ns:SimpleUser"
        type="java:siag.security.soap.ws.SimpleUser"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
      />
  </service>
</deployment>


What's wrong?
/*
 * Created on 21.10.2004
 *
 * Karl-Heinz Sergel
 * www.wiederda.com
 */
package siag.security.soap.ws;

import java.rmi.RemoteException;

/**
 *
 * Copyright 2001-2004 by Serkom
 * @author <a href="mailto:[EMAIL PROTECTED]">Karl-Heinz Sergel </a>
 * 
 * 
 */
public class SecuritySoapBindingImpl {

  public SimpleUser findNameByPK(int id) throws RemoteException {
    SimpleUser su = new SimpleUser();  
    su.setId(12);
    su.setNome("Marco Rossi");
            
    return su;
      
  }
}
/**
 * SecuritySoapBindingStub.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 */

package siag.security.soap.ws;

public class SecuritySoapBindingStub extends org.apache.axis.client.Stub implements SoapUser {
    private java.util.Vector cachedSerClasses = new java.util.Vector();
    private java.util.Vector cachedSerQNames = new java.util.Vector();
    private java.util.Vector cachedSerFactories = new java.util.Vector();
    private java.util.Vector cachedDeserFactories = new java.util.Vector();

    static org.apache.axis.description.OperationDesc [] _operations;

    static {
        _operations = new org.apache.axis.description.OperationDesc[1];
        org.apache.axis.description.OperationDesc oper;
        oper = new org.apache.axis.description.OperationDesc();
        oper.setName("findNameByPK");
        oper.addParameter(new javax.xml.namespace.QName("", "id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema";, "int"), int.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.setReturnType(new javax.xml.namespace.QName("urn:siag.security.soap", "SimpleUser"));
        oper.setReturnClass(SimpleUser.class);
        oper.setReturnQName(new javax.xml.namespace.QName("", "findNameByPKReturn"));
        oper.setStyle(org.apache.axis.enum.Style.RPC);
        oper.setUse(org.apache.axis.enum.Use.ENCODED);
        _operations[0] = oper;

    }

    public SecuritySoapBindingStub() throws org.apache.axis.AxisFault {
         this(null);
    }

    public SecuritySoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
         this(service);
         super.cachedEndpoint = endpointURL;
    }

    public SecuritySoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
        if (service == null) {
            super.service = new org.apache.axis.client.Service();
        } else {
            super.service = service;
        }
            java.lang.Class cls;
            javax.xml.namespace.QName qName;
            java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;
            java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;
            java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class;
            java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class;
            java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class;
            java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class;
            java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class;
            java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class;
            qName = new javax.xml.namespace.QName("urn:siag.security.soap", "SimpleUser");
            cachedSerQNames.add(qName);
            cls = SimpleUser.class;
            cachedSerClasses.add(cls);
            cachedSerFactories.add(beansf);
            cachedDeserFactories.add(beandf);

    }

    private org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
        try {
            org.apache.axis.client.Call _call =
                    (org.apache.axis.client.Call) super.service.createCall();
            if (super.maintainSessionSet) {
                _call.setMaintainSession(super.maintainSession);
            }
            if (super.cachedUsername != null) {
                _call.setUsername(super.cachedUsername);
            }
            if (super.cachedPassword != null) {
                _call.setPassword(super.cachedPassword);
            }
            if (super.cachedEndpoint != null) {
                _call.setTargetEndpointAddress(super.cachedEndpoint);
            }
            if (super.cachedTimeout != null) {
                _call.setTimeout(super.cachedTimeout);
            }
            if (super.cachedPortName != null) {
                _call.setPortName(super.cachedPortName);
            }
            java.util.Enumeration keys = super.cachedProperties.keys();
            while (keys.hasMoreElements()) {
                java.lang.String key = (java.lang.String) keys.nextElement();
                _call.setProperty(key, super.cachedProperties.get(key));
            }
            // All the type mapping information is registered
            // when the first call is made.
            // The type mapping information is actually registered in
            // the TypeMappingRegistry of the service, which
            // is the reason why registration is only needed for the first call.
            synchronized (this) {
                if (firstCall()) {
                    // must set encoding style before registering serializers
                    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
                    _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
                    for (int i = 0; i < cachedSerFactories.size(); ++i) {
                        java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i);
                        javax.xml.namespace.QName qName =
                                (javax.xml.namespace.QName) cachedSerQNames.get(i);
                        java.lang.Class sf = (java.lang.Class)
                                 cachedSerFactories.get(i);
                        java.lang.Class df = (java.lang.Class)
                                 cachedDeserFactories.get(i);
                        _call.registerTypeMapping(cls, qName, sf, df, false);
                    }
                }
            }
            return _call;
        }
        catch (java.lang.Throwable t) {
            throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
        }
    }

    public SimpleUser findNameByPK(int id) throws java.rmi.RemoteException {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[0]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("");
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("urn:siag.security.soap", "findNameByPK"));

        setRequestHeaders(_call);
        setAttachments(_call);
        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Integer(id)});

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        }
        else {
            extractAttachments(_call);
            try {
                return (SimpleUser) _resp;
            } catch (java.lang.Exception _exception) {
                return (SimpleUser) org.apache.axis.utils.JavaUtils.convert(_resp, SimpleUser.class);
            }
        }
    }

}
/*
 * Created on 21.10.2004
 * 
 * Karl-Heinz Sergel www.wiederda.com
 */
package siag.security.soap.ws;

import java.io.Serializable;

public class SimpleUser implements Serializable {
  public int id;
  public String nome;
  
  public SimpleUser() {	}

	/**
	 * @return Returns the id.
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *          The id to set.
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return Returns the nome.
	 */
	public String getNome() {
		return nome;
	}

	/**
	 * @param nome
	 *          The nome to set.
	 */
	public void setNome(String nome) {
		this.nome = nome;
	}

	public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append(super.toString()).append(" / ");
    sb.append(getId()).append(" / ").append(getNome());
    return sb.toString(); 
  }

}

/*
 * Created on 21.10.2004
 *
 * Karl-Heinz Sergel
 * www.wiederda.com
 */
package siag.security.soap.ws;

public interface SoapUser extends java.rmi.Remote {
    public SimpleUser findNameByPK(int id) throws java.rmi.RemoteException;

}
/**
 * SoapUserService.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 */

package siag.security.soap.ws;

public interface SoapUserService extends javax.xml.rpc.Service {
    public java.lang.String getsecurityAddress();

    public SoapUser getsecurity() throws javax.xml.rpc.ServiceException;

    public SoapUser getsecurity(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
}
/**
 * SoapUserServiceLocator.java
 * 
 * This file was auto-generated from WSDL by the Apache Axis WSDL2Java emitter.
 */

package siag.security.soap.ws;

public class SoapUserServiceLocator extends org.apache.axis.client.Service
		implements SoapUserService {

	// Use to get a proxy class for security
	private final java.lang.String security_address = "http://192.100.100.222:8080/axis/services/security";;

	public java.lang.String getsecurityAddress() {
		return security_address;
	}

	// The WSDD service name defaults to the port name.
	private java.lang.String securityWSDDServiceName = "security";

	public java.lang.String getsecurityWSDDServiceName() {
		return securityWSDDServiceName;
	}

	public void setsecurityWSDDServiceName(java.lang.String name) {
		securityWSDDServiceName = name;
	}

	public SoapUser getsecurity() throws javax.xml.rpc.ServiceException {
		java.net.URL endpoint;
		try {
			endpoint = new java.net.URL(security_address);
		} catch (java.net.MalformedURLException e) {
			throw new javax.xml.rpc.ServiceException(e);
		}
		return getsecurity(endpoint);
	}

	public SoapUser getsecurity(java.net.URL portAddress)
			throws javax.xml.rpc.ServiceException {
		try {
			SecuritySoapBindingStub _stub = new SecuritySoapBindingStub(portAddress,
					this);
			_stub.setPortName(getsecurityWSDDServiceName());
			return _stub;
		} catch (org.apache.axis.AxisFault e) {
			return null;
		}
	}

	/**
	 * For the given interface, get the stub implementation. If this service has
	 * no port for the given interface, then ServiceException is thrown.
	 */
	public java.rmi.Remote getPort(Class serviceEndpointInterface)
			throws javax.xml.rpc.ServiceException {
		try {
			if (SoapUser.class.isAssignableFrom(serviceEndpointInterface)) {
				SecuritySoapBindingStub _stub = new SecuritySoapBindingStub(
						new java.net.URL(security_address), this);
				_stub.setPortName(getsecurityWSDDServiceName());
				return _stub;
			}
		} catch (java.lang.Throwable t) {
			throw new javax.xml.rpc.ServiceException(t);
		}
		throw new javax.xml.rpc.ServiceException(
				"There is no stub implementation for the interface:  "
						+ (serviceEndpointInterface == null ? "null"
								: serviceEndpointInterface.getName()));
	}

	/**
	 * For the given interface, get the stub implementation. If this service has
	 * no port for the given interface, then ServiceException is thrown.
	 */
	public java.rmi.Remote getPort(javax.xml.namespace.QName portName,
			Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
		if (portName == null) {
			return getPort(serviceEndpointInterface);
		}
		String inputPortName = portName.getLocalPart();
		if ("security".equals(inputPortName)) {
			return getsecurity();
		} else {
			java.rmi.Remote _stub = getPort(serviceEndpointInterface);
			((org.apache.axis.client.Stub) _stub).setPortName(portName);
			return _stub;
		}
	}

	public javax.xml.namespace.QName getServiceName() {
		return new javax.xml.namespace.QName("urn:siag.security.soap",
				"SoapUserService");
	}

	private java.util.HashSet ports = null;

	public java.util.Iterator getPorts() {
		if (ports == null) {
			ports = new java.util.HashSet();
			ports.add(new javax.xml.namespace.QName("security"));
		}
		return ports.iterator();
	}

}
/**
 * SoapUserServiceTestCase.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 */

package siag.security.soap.ws;

public class SoapUserServiceTestCase extends junit.framework.TestCase {
    public SoapUserServiceTestCase(java.lang.String name) {
        super(name);
    }
    public void test1securityFindNameByPK() throws Exception {
        SecuritySoapBindingStub binding;
        try {
            binding = (SecuritySoapBindingStub)
                          new SoapUserServiceLocator().getsecurity();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if(jre.getLinkedCause()!=null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
        }
        assertNotNull("binding is null", binding);

        // Time out after a minute
        binding.setTimeout(60000);

        // Test operation
        SimpleUser value = null;
        value = binding.findNameByPK(0);
        System.out.println(value.toString());
        // TBD - validate results
    }

}

Reply via email to