[JBossWS] - Service endpoint and client generation problem
by joestevens
Hi,
I'm working on a small ws project to get my feet wet. Things were moving along, but got complicated enough that it was time to add some automation to the build. I'm using the bottom-up approach for my endpoint as outlined in the JAX-WS Tools section of the wiki. I wrote the implementation, added the annotations, and the wsdl got generated. Worked great.
Next, I decided to use the wsdl to generate client support code. I set up an ant task using wsconsume, and everything generated fine. So, I created a little test client using the generated code, ran it, and everything worked. Sweet. Writing software is easy.
As soon as that thought crossed my mind, the software gods decided to punish me for my hubris. If I clean out the build and recompile and regenerate, the build breaks. In order to generate the client support classes, wsconsume needs the wsdl. In order to generate the wsdl, wsprovide needs the endpoint class file. In order to compile the endpoint the client support classes are needed because the client depends on them and they are in the same source tree. So, I have a chicken and egg problem.
The only way that jumps to mind to fix this is to have separate source trees for the endpoint and the client code. That feels kind of clunky. It seems reasonable to have an endpoint implementation, client support classes, and a client in the same source tree. Do most people separate client and server or are there other solutions I'm not thinking of?
If you're still reading, thanks. Any ideas are appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152498#4152498
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152498
16 years, 9 months
[JBossWS] - Re: Marshall Object List
by bsisson
I was able to figure out and here is sample code that produces a marshalled XML output string from objects and object lists.
Here is the testing Class (Used to create the object instances and then marshall them):
package org.xmlmarshalling2.com;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
public class RunItemTest
{
public static void main(String[] args)
{
System.out.println("test");
Items todo = new Items();
todo.setTitle("Beginning!!!");
List items = todo.getItem();
Item i1 = new Item();
i1.setId("001");
i1.setName("Dog");
i1.setPrice("$3.99");
items.add(i1);
Item i2 = new Item();
i2.setId("002");
i2.setName("Cat");
i2.setPrice("$2.99");
items.add(i2);
Item i3 = new Item();
i3.setId("003");
i3.setName("Fish");
i3.setPrice("$1.99");
items.add(i3);
try
{
JAXBContext context = JAXBContext.newInstance(Items.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(todo, System.out);
}
catch (Exception e)
{
System.out.println("Error: " + e.getMessage());
}
}
}
Here is a base class (this class contains a reference to the object list):
package org.xmlmarshalling2.com;
import java.util.*;
import javax.xml.bind.annotation.*;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"title", "item"
})
@XmlRootElement(name = "Items")
public class Items {
protected String title;
@XmlElement(name = "Item")
protected List item;
public List getItem()
{
if (item == null) {
item = new ArrayList();
}
return this.item;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
}
Here is the class that the object list is created from:
package org.xmlmarshalling2.com;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.*;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"name",
"price"
})
@XmlRootElement(name = "Item")
public class Item {
@XmlElement(name = "Name")
protected String name;
@XmlElement(name = "Price")
protected String price;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String id;
public String getName() {
return name;
}
public void setName(String value) {
this.name = value;
}
public String getPrice() {
return price;
}
public void setPrice(String value) {
this.price = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152467#4152467
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152467
16 years, 9 months
[JBossWS] - Load balancer problem
by tnfink
Hi,
we are developing a clustered application with webservices as interface for the clients. We use Apache and mod_jk for load-balancing and fail-over and JBoss 4.2.2 in the all configuration.
To measure the performance of our system we implemented a small load test application. It uses some threads to send requests concurrently to the server. Each thread uses one (its own) web service stub.
It appears that the stub reuses its connection and, thus, the requests are not dispatched by the load-balancer. We see in the mod_jk-status page much less requests than our threads created.
Does anybody know, if connections are reused?
If yes, how can we avoid this?
We tried to disable the maintaining of sessions, but it had no effect:
| final javax.xml.ws.BindingProvider bp =
| (javax.xml.ws.BindingProvider) paymentServicePort;
| final Map<String, Object> context = bp.getRequestContext();
| context.put("javax.xml.ws.session.maintain", Boolean.FALSE);
|
Any help would be greatly appreciated!
-- Torsten
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152393#4152393
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152393
16 years, 9 months
[JBossWS] - Marshall Object List
by bsisson
I'm trying to marshall a list containing objects into an XML string. I was able to marshall a single object into an XML string but am struggling on what is needed to do a list?
I am including an example using JBoss Tools Web Services. It will query the database and receive a back a list of WebCalendar objects. If I create a single object and marshall it will work. However, I need to marshall the list so that it creates multiple entries for each object in the marshalled XML. If you can advise I would appreciate it.
Here is an example code:
This is the class that will query the database which returns a list of WebPayCalendar objects I then try to marshall the list into an XML string:
@WebMethod
public String retrievePsWebPayCalendar()
{
try
{
/**************************************************************************
* The following example marshals an object class into an XML string which
* is returned to the caller. The object is an entity representing a
* row on the database.
**************************************************************************/
WebPayCalendarList selectCalendar = (WebPayCalendarList) Component.getInstance("webPayCalendarList");
// Retrieve the entire list of web pay calendar dates
List pc = selectCalendar.getResultList();
// For a test retrieve only the first web calendar date object
WebPayCalendar wpc = pc.get(0);
// Marshal the calendar information into an XML string and return it
JAXBContext context = JAXBContext.newInstance(WebPayCalendar.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(pc, System.out);
return result.getWriter().toString();
}
catch (Exception e)
{
return "Error: " + e.getMessage();
}
}
This is the object Class:
package org.domain.PSWebService.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.hibernate.validator.Length;
@Entity
@Table(name="WEB_PAY_CALENDAR", uniqueConstraints = {@UniqueConstraint(columnNames={"RUN_ID"})})
@XmlRootElement
public class WebPayCalendar implements Serializable
{
//WEB_PAY_CALENDAR Data Columns
@Length(max=3)
private String payGroup;
@Id
@Length(max=10)
@Column(name="RUN_ID")
private String runId;
@Column(name="CHECK_DT")
private java.util.Date checkDt;
@Column(name="PAY_BEGIN_DT")
private java.util.Date payBeginDt;
@Column(name="PAY_END_DT")
private java.util.Date payEndDt;
@Length(max=1)
@Column(name="PAY_CONFIRM_RUN")
private String payConfirmRun;
public String getPayGroup()
{
return payGroup;
}
public void setPayGroup(String payGroup)
{
this.payGroup = payGroup;
}
public String getRunId()
{
return runId;
}
public void setRunId(String runId)
{
this.runId = runId;
}
public java.util.Date getCheckDt()
{
return checkDt;
}
public void setCheckDt(java.util.Date checkDt)
{
this.checkDt = checkDt;
}
public java.util.Date getPayBeginDt()
{
return payBeginDt;
}
public void setPayBeginDt(java.util.Date payBeginDt)
{
this.payBeginDt = payBeginDt;
}
public java.util.Date getPayEndDt()
{
return payEndDt;
}
public void setPayEndDt(java.util.Date payEndDt)
{
this.payEndDt = payEndDt;
}
public String getPayConfirmRun()
{
return payConfirmRun;
}
public void setPayConfirmRun(String payConfirmRun)
{
this.payConfirmRun = payConfirmRun;
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152353#4152353
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152353
16 years, 9 months