| Does Axis assume that a class with getName and setName methods also has a
field named "name"? I have an example where my get/set methods operate on
"_name", and it causes problems for Axis.
no.
Please give me a little more input. Did you start with the wsdl
(containing the upper-case names) and use it
to generate your PurchaseOrder bean ? By default, the bean (without
meta-data) will serialize getCustomerName as
customerName according to the JSR 101 mapping.
If you want different behaviour you will need to include meta-data in your
bean. There are two ways to do this:
1) generate the bean with WSDL2Java, and the meta-data data (in this case
capitalized QNames) will be embedded in the bean.
2) generate the bean with WSDL2Java -H, and the meta-data will be placed in
a separate helper class.
Please let me know if you need additional help with this.
Rich Scheuerle
XML & Web Services Development
512-838-5115 (IBM TL 678-5115)
"Jim Dibble"
<jdibble@amberpoi To: <[EMAIL PROTECTED]>
nt.com> cc:
Subject: Problems with Axis's XML<-->
Java Mapping
05/24/2002 05:34
PM
Please respond to
axis-user
I'm encountering problems with Axis's XML�> Java mapping.
Does Axis assume that a class with getName and setName methods also has a
field named "name"? I have an example where my get/set methods operate on
"_name", and it causes problems for Axis.
I created a class PurchaseOrder that is sent as a parameter to my service.
The class looks like this:
public class PurchaseOrder
{
private String _id;
private String _customerName;
private String _address;
private String _city;
private String _state;
private java.util.Vector _itemVector;
OrderItem[] itemArray = new OrderItem[] {};
public PurchaseOrder()
{
_itemVector = new Vector();
}
public String getId()
{
return _id;
}
public void setId(String id)
{
_id = id;
}
public String getCustomerName()
{
return _customerName;
}
public void setCustomerName(String customerName)
{
_customerName = customerName;
}
public String getAddress()
{
return _address;
}
public void setAddress(String address)
{
_address = address;
}
public String getCity()
{
return _city;
}
public void setCity(String city)
{
_city = city;
}
public String getState()
{
return _state;
}
public void setState(String state)
{
_state = state;
}
public OrderItem[] getItems()
{
return (OrderItem[])(_itemVector.toArray(itemArray));
}
public void setItems(OrderItem[] items)
{
for (int i=0; i < items.length; i++)
{
_itemVector.addElement(items[i]);
}
}
protected void addItem(OrderItem item)
{
_itemVector.addElement(item);
}
}
There's also a similar OrderItem class, with fields beginning with "_".
My wsdd file contains beanMapping entries like this:
<beanMapping qname="ord:PurchaseOrder" languageSpecificType
="java:com.amberpoint.tutorial.orders.PurchaseOrder"/>
<beanMapping qname="ord:OrderItem" languageSpecificType="
java:com.amberpoint.tutorial.orders. OrderItem"/>
When I generate client code and write a test client, I run into a problem
when I send a message to the web service. The client seems to generate an
XML document with elements beginning with upper-case characters:
<CustomerName>Cole Hardware</CustomerName>
<City>San Francisco</City>
<State>CA</State>
But Axis does not seem to recognize the elements if they start with
upper-case characters. (I changed them by hand to lower-case characters,
and the problem went away).
My service also has a method that returns a PurchaseOrder as a return
value. I notice that the response SOAP message for this operation uses
lower-case characters for the element names. It seems like the generated
client code is capable of handling the lower-case version, but produces the
upper-case version. The Axis server code can only handle the lower-case
version, and always produces the lower-case version.
Note that the schema in the generated WSDL file contains all elements
starting with an upper-case character.
Is this a known bug? Is there any workaround other than rewriting the code
for my parameter classes so that field names match getter/setter names?
Jim