[JBossWS] - Re: trying to access a webservice - not working from either
by rodgerca
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
18Â years, 9Â months
[JBoss Seam] - Re: c:forEach and h:column
by limousyf
Ok, after using a Datamodel for the lines and a List for the columns, I finally managed to get this (half-)working.
To get the correct Cell, containing my object, I :
- iterate over lines using isRowAvailable() and getRowData()
- iterate over the columns using an int going from 0 to myList.size()
in a method named getCellValue() in my backing bean.
This works pretty well If I fetch only one time the cell content (the column counter is incremented one time per cell).
But If need to fetch multiple times the cell (it's an object containing the value, a boolean for rendering, etc ...) then it doesn't work.
My column counter is incremented bean-side, so it doesn't care if I'm still on the same cell jsf-side ...
When I was using DataModel for both lines and columns (JSP/Myfaces project, before Seam), isRowAvailable() and getRowData() used to handle increment neatly.
Am I missing something here ?
BTW, a portion of code from my backing bean
| public CELLOBJECT getCellValue(){
| DataModel lineDataModel = getLineDataModel();
| if (lineDataModel.isRowAvailable()) {
| Line line = (Line) lineDataModel.getRowData();
|
| if(compteurColonnes >= this.getColumnList().size()){
| compteurColonnes = 0;
| }
|
| for (Iterator<Cell<CELLOBJECT>> it = line.getCellList().iterator(); it.hasNext();) {
| Cell<CELLOBJECT> cell = it.next();
| if (cell.getColumnId() == compteurColonnes) {
| System.out.println("[ " + cell.getLineId() + " , " + cell.getColumnId() + " ] = " + cell.getCellValue().toString());
| compteurColonnes++;
| return cell.getCellValue();
| }
| }
|
| }
| return cellValue;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067093#4067093
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067093
18Â years, 9Â months
[JBossWS] - Cannot get details in custon fault
by bossy
I need to throw a custom exception from a web service. The problem is I don't get the details.
I'm running my WS under jboss 4.0.4.
My wsdl contains the following :
| <xsd:element name="MyOperationFault">
| <xsd:complexType>
| <xsd:sequence>
| <xsd:element name="MyOperationFaultCode" type="xsd:string" />
| <xsd:element name="MyOperationFaultSeverity" type="xsd:string" />
| <xsd:element name="MyOperationFaultMessage" type="xsd:string" />
| <xsd:element name="MyOperationFaultComment" type="xsd:string" />
| </xsd:sequence>
| </xsd:complexType>
| </xsd:element>
| </xsd:schema>
| </wsdl:types>
|
| <wsdl:message name="MyOperationRequest">
| <wsdl:part element="tns:MyOperationRequest" name="parameters"/>
| </wsdl:message>
| <wsdl:message name="MyOperationResponse">
| <wsdl:part element="tns:MyOperationResponse" name="parameters"/>
| </wsdl:message>
|
|
|
|
| <wsdl:message name="MyOperationFault">
| <wsdl:part name="parameters" element="tns:MyOperationFault"></wsdl:part>
| </wsdl:message>
| <wsdl:portType name="Test">
| <wsdl:operation name="MyOperation">
| <wsdl:input message="tns:MyOperationRequest"/>
| <wsdl:output message="tns:MyOperationResponse"/>
| <wsdl:fault name="MyOperationException" message="tns:MyOperationFault"></wsdl:fault>
| </wsdl:operation>
|
| </wsdl:portType>
|
| <wsdl:binding name="TestSOAP" type="tns:Test">
| <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
|
| <wsdl:operation name="MyOperation">
| <soap:operation soapAction="http://www.mycom.com/Test/MyOperation"/>
| <wsdl:input><soap:body use="literal"/></wsdl:input>
| <wsdl:output><soap:body use="literal"/></wsdl:output>
| <wsdl:fault name="MyOperationException" >
| <soap:fault name="MyOperationException"/>
| </wsdl:fault>
| </wsdl:operation>
|
| </wsdl:binding>
My mapping file contains this:
|
|
| <java-xml-type-mapping>
| <java-type>com.mycom.myapp.ws.types.MyOperationFault</java-type>
| <root-type-qname xmlns:typeNS="http://www.mycom.com/Test/">typeNS:MyOperationFault</root-type-qname>
| <qname-scope>complexType</qname-scope>
| <variable-mapping>
| <java-variable-name>MyOperationFaultCode</java-variable-name>
| <xml-element-name>MyOperationFaultCode</xml-element-name>
| </variable-mapping>
| <variable-mapping>
| <java-variable-name>MyOperationFaultSeverity</java-variable-name>
| <xml-element-name>MyOperationFaultSeverity</xml-element-name>
| </variable-mapping>
| <variable-mapping>
| <java-variable-name>MyOperationFaultMessage</java-variable-name>
| <xml-element-name>MyOperationFaultMessage</xml-element-name>
| </variable-mapping>
| <variable-mapping>
| <java-variable-name>MyOperationFaultComment</java-variable-name>
| <xml-element-name>MyOperationFaultComment</xml-element-name>
| </variable-mapping>
| </java-xml-type-mapping>
|
|
| <exception-mapping>
| <exception-type>com.mycom.myapp.ws.types.MyOperationFault</exception-type>
| <wsdl-message xmlns:exMsgNS="http://www.mycom.com/Test/">exMsgNS:MyOperationFault</wsdl-message>
| <constructor-parameter-order>
| <element-name>MyOperationFaultCode</element-name>
| <element-name>MyOperationFaultSeverity</element-name>
| <element-name>MyOperationFaultMessage</element-name>
| <element-name>MyOperationFaultComment</element-name>
| </constructor-parameter-order>
| </exception-mapping>
|
| <service-interface-mapping>
| <service-interface>com.mycom.myapp.ws.serviceTestService</service-interface>
| <wsdl-service-name xmlns:serviceNS="http://www.mycom.com/Test/">serviceNS:TestService</wsdl-service-name>
| <port-mapping>
| <port-name>TestSOAP</port-name>
| <java-port-name>TestSOAP</java-port-name>
| </port-mapping>
| </service-interface-mapping>
|
|
| <service-endpoint-interface-mapping>
|
| <service-endpoint-interface>com.mycom.myapp.ws.Test</service-endpoint-interface>
| <wsdl-port-type xmlns:portTypeNS="http://www.mycom.com/Test/">portTypeNS:Test</wsdl-port-type>
| <wsdl-binding xmlns:bindingNS="http://www.mycom.com/Test/">bindingNS:TestSOAP</wsdl-binding>
|
|
|
|
| <service-endpoint-method-mapping>
| <java-method-name>MyOperation</java-method-name>
| <wsdl-operation>MyOperation</wsdl-operation>
| <wrapped-element/>
|
| <method-param-parts-mapping>
| <param-position>0</param-position>
| <param-type>java.lang.String</param-type>
| <wsdl-message-mapping>
| <wsdl-message xmlns:wsdlMsgNS="http://www.mycom.com/Test/">wsdlMsgNS:MyOperationRequest</wsdl-message>
| <wsdl-message-part-name>par1</wsdl-message-part-name>
| <parameter-mode>IN</parameter-mode>
| </wsdl-message-mapping>
| </method-param-parts-mapping>
|
| <method-param-parts-mapping>
| <param-position>1</param-position>
| <param-type>java.lang.String</param-type>
| <wsdl-message-mapping>
| <wsdl-message xmlns:wsdlMsgNS="http://www.mycom.com/Test/">wsdlMsgNS:MyOperationRequest</wsdl-message>
| <wsdl-message-part-name>par2</wsdl-message-part-name>
| <parameter-mode>IN</parameter-mode>
| </wsdl-message-mapping>
| </method-param-parts-mapping>
|
| <wsdl-return-value-mapping>
| <method-return-value>com.mycom.myapp.ws.api.MyOperationResponse</method-return-value>
| <wsdl-message xmlns:wsdlMsgNS="http://www.mycom.com/Test/">wsdlMsgNS:MyOperationResponse</wsdl-message>
| <wsdl-message-part-name>parameters</wsdl-message-part-name>
| </wsdl-return-value-mapping>
|
| </service-endpoint-method-mapping>
| </service-endpoint-interface-mapping>
|
|
and this is how my methods are declared:
| public MyOperationResponse MyOperation(MyOperationRequest request) throws RemoteException,MyOperationFault;
|
MyOperationFault extends extends Exception implements Serializable
The problem is that when I throw MyOperationFault I get this:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
| <env:Header/>
| <env:Body>
| <env:Fault>
| <faultcode>env:Client</faultcode>
| <faultstring>com.mycom.myapp.ws.types.MyOperationFault</faultstring>
| </env:Fault>
| </env:Body>
| </env:Envelop>
I would expect to see also an element "detail" with the rest of the MyOperationFault properties.Can somebody point me the right direction what am I doing wrong?
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067089#4067089
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067089
18Â years, 9Â months