I generated the wsdl from the code

Here is the code:-

****************INTERFACE******************

package com.cmmgroup.address.session;
import java.rmi.Remote;
import java.util.List;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import com.cmmgroup.address.entities.POAddress;

@WebService
@SOAPBinding(style = javax.jws.soap.SOAPBinding.Style.RPC)
public interface POAddressManagerWS extends Remote {

        @SuppressWarnings("unchecked")
        public List getAddressByPostCode(String postCode);
        @SuppressWarnings("unchecked")
        public List getAddressByText(String textString);

}

*********************SESSION BEAN********************8

package com.cmmgroup.address.session;

import java.io.Serializable;
import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.cmmgroup.address.entities.POAddress;
@Stateless
@WebService(endpointInterface = 
"com.cmmgroup.address.session.POAddressManagerWS")
public class POAddressManagerBean implements Serializable, 
POAddressManagerRemote, POAddressManagerLocal, POAddressManagerWS {
        
        private static final long serialVersionUID = 1L;
        
        @PersistenceContext(unitName="phoebusDS")
        private EntityManager em;
        
        @SuppressWarnings("unchecked")
        public List getAddressByPostCode(String postCode) {
                
                Query query = em.createNamedQuery("getAddrByPC");
                query.setParameter("pc",postCode + "%");
                
                return query.getResultList();
        }
        
        @SuppressWarnings("unchecked")
        public List getAddressByText(String textString) {
                
                Query query = em.createNamedQuery("getAddrByText");
                query.setParameter("text",textString);
                
                return query.getResultList();
        }
}
*********************ENTITY BEAN****************
package com.cmmgroup.address.entities;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.Table;

@NamedNativeQueries({
        @NamedNativeQuery(name="getAddrByPC",query="select id, postCode, 
thoroughFare1, thoroughFare2, locality1, locality2, post_town, county from 
postcodes where postCode like :pc",resultClass=POAddress.class),
        @NamedNativeQuery(name="getAddrByText",query="select id, postCode, 
thoroughFare1, thoroughFare2, locality1, locality2, post_town, county from 
postcodes where CATSEARCH(address, :text,null)> 0",resultClass=POAddress.class),
        })
@Entity
@Table(name="POSTCODES")
public class POAddress implements Serializable{
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        @Id
        private long id;
        private String postCode;
        private String thoroughFare1;
        private String thoroughFare2;
        private String locality1;
        private String locality2;
        private String post_Town;
        private String county;
        
        public POAddress() {
                super();
        }

        public POAddress(String postCode, String thoroughFare1, String 
thoroughFare2, String locality1, String locality2, String post_Town, String 
county) {
                super();
                this.postCode = postCode;
                this.thoroughFare1 = thoroughFare1;
                this.thoroughFare2 = thoroughFare2;
                this.locality1 = locality1;
                this.locality2 = locality2;
                this.post_Town = post_Town;
                this.county = county;
        }

        public String getCounty() {
                return county;
        }

        public void setCounty(String county) {
                this.county = county;
        }

        public String getLocality1() {
                return locality1;
        }

        public void setLocality1(String locality1) {
                this.locality1 = locality1;
        }

        public String getLocality2() {
                return locality2;
        }

        public void setLocality2(String locality2) {
                this.locality2 = locality2;
        }

        public String getPostCode() {
                return postCode;
        }

        public void setPostCode(String postCode) {
                this.postCode = postCode;
        }

        public String getPostTown() {
                return post_Town;
        }

        public void setPostTown(String postTown) {
                this.post_Town = postTown;
        }

        public String getThoroughFare1() {
                return thoroughFare1;
        }

        public void setThoroughFare1(String thoroughFare1) {
                this.thoroughFare1 = thoroughFare1;
        }

        public String getThoroughFare2() {
                return thoroughFare2;
        }

        public void setThoroughFare2(String thoroughFare2) {
                this.thoroughFare2 = thoroughFare2;
        }

        public long getId() {
                return id;
        }

        public void setId(long id) {
                this.id = id;
        }

        public String getPost_Town() {
                return post_Town;
        }

        public void setPost_Town(String post_Town) {
                this.post_Town = post_Town;
        }
}

The bean runs fine when using the remote or local interface

***************************MY TEST STUB***************

package com.cmmgroup.address.client;

import java.net.URL;

import javax.xml.namespace.QName;

//import org.jboss.system.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

import com.cmmgroup.address.entities.POAddress;
import com.cmmgroup.address.session.POAddressManagerWS;

public class RunAddressAsWebService {
    public static void main(String[] args) throws Exception {
        System.out.println("Starting Test Client");
        URL url = new 
URL("http://127.0.0.1:8080/POAddressManagerBeanService/POAddressManagerBean?wsdl";);
        QName qname = new QName(
                        "http://session.address.cmmgroup.com/";,
                        "POAddressManagerBeanService");

        System.out.println("Creating a service Using: \n\t" 
                                   + url + " \n\tand " + qname);
        ServiceFactory factory = ServiceFactory.newInstance();
        System.out.println("Created new instance");
        
        Service remote = factory.createService(url, qname);

        System.out.println("Obtaining reference to a proxy object");
        POAddressManagerWS proxy = (POAddressManagerWS) 
remote.getPort(POAddressManagerWS.class);
        System.out.println("Accessed local proxy: " + proxy);
       
                for(POAddress address:proxy.getAddressByPostCode("IP4 4B"))
                {
                        System.out.println(address.getThoroughFare1() + " " + 
address.getPostCode());
                }
             
   }
}

********************WSDL INTERFACE GENERATED**********

<definitions name="POAddressManagerBeanService" 
targetNamespace="http://session.address.cmmgroup.com/"; 
xmlns="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:tns="http://session.address.cmmgroup.com/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
- 
- <xs:schema targetNamespace="http://session.address.cmmgroup.com/"; 
version="1.0" xmlns:tns="http://session.address.cmmgroup.com/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <xs:element name="getAddressByPostCode" type="tns:getAddressByPostCode" /> 
  <xs:element name="getAddressByPostCodeResponse" 
type="tns:getAddressByPostCodeResponse" /> 
  <xs:element name="getAddressByText" type="tns:getAddressByText" /> 
  <xs:element name="getAddressByTextResponse" 
type="tns:getAddressByTextResponse" /> 
- <xs:complexType name="getAddressByPostCode">
- <xs:sequence>
  <xs:element minOccurs="0" name="arg0" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="getAddressByPostCodeResponse">
- <xs:sequence>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="return" 
type="tns:poAddress" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="poAddress">
- <xs:sequence>
  <xs:element minOccurs="0" name="county" type="xs:string" /> 
  <xs:element name="id" type="xs:long" /> 
  <xs:element minOccurs="0" name="locality1" type="xs:string" /> 
  <xs:element minOccurs="0" name="locality2" type="xs:string" /> 
  <xs:element minOccurs="0" name="postCode" type="xs:string" /> 
  <xs:element minOccurs="0" name="postTown" type="xs:string" /> 
  <xs:element minOccurs="0" name="post_Town" type="xs:string" /> 
  <xs:element minOccurs="0" name="thoroughFare1" type="xs:string" /> 
  <xs:element minOccurs="0" name="thoroughFare2" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="getAddressByText">
- <xs:sequence>
  <xs:element minOccurs="0" name="arg0" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="getAddressByTextResponse">
- <xs:sequence>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="return" 
type="tns:poAddress" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
  
- 
   
  
- 
   
  
- 
   
  
- 
   
  
- 
- 
   
   
  
- 
   
   
  
  
- 
  <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"; /> 
- 
  <soap:operation soapAction="" /> 
- 
  <soap:body use="literal" /> 
  
- 
  <soap:body use="literal" /> 
  
  
- 
  <soap:operation soapAction="" /> 
- 
  <soap:body use="literal" /> 
  
- 
  <soap:body use="literal" /> 
  
  
  
- 
- 
  <soap:address 
location="http://127.0.0.1:8080/POAddressManagerBeanService/POAddressManagerBean";
 /> 
  
  
  

Enjoy ;-)


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067094#4067094

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067094
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to