You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by mvkirankumar <ki...@gmail.com> on 2007/01/28 22:23:03 UTC

[AXIS2] How to transfer XML from Axis2 Webservice to any client (.net/java/* any client)

Hi,

How to transfer XML from Axis2 Webservice to any client (.net/java/* any
client)?

I decided to use JIBX binding framework and now got stuck as below.
I also have attached the binding.xml, binding.xsd, *.wsdl file at the end.

If my approach is wrong, please suggest me with a better one.

Scenario:

I have the following beans:

1. Customerbean
----------------------
package com.db.ws.pace.shared;

public class CustomerBean {
	private String customerFirstName;
	private String customreLastName;
	private int customerNo;
	private Address customerAddress;
	public Address getCustomerAddress() {
		return customerAddress;
	}
	public void setCustomerAddress(Address customerAddress) {
		this.customerAddress = customerAddress;
	}
	public String getCustomerFirstName() {
		return customerFirstName;
	}
	public void setCustomerFirstName(String customerFirstName) {
		this.customerFirstName = customerFirstName;
	}
	public int getCustomerNo() {
		return customerNo;
	}
	public void setCustomerNo(int customerNo) {
		this.customerNo = customerNo;
	}
	public String getCustomreLastName() {
		return customreLastName;
	}
	public void setCustomreLastName(String customreLastName) {
		this.customreLastName = customreLastName;
	}
}
====-------------------================
2. Address bean

package com.db.ws.pace.shared;

public class Address {
	private String streetNo;
	private String streetName;
	private String aptNo;
	private String city;
	private String state;
	private String country;
	public String getAptNo() {
		return aptNo;
	}
	public void setAptNo(String aptNo) {
		this.aptNo = aptNo;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getStreetName() {
		return streetName;
	}
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	public String getStreetNo() {
		return streetNo;
	}
	public void setStreetNo(String streetNo) {
		this.streetNo = streetNo;
	}
}

------=========----------------
3. CustomerService

/**
 * 
 */
package com.db.ws.pace.server;

import com.db.ws.pace.shared.CustomerBean;



/**
 * @author kumakir
 *
 */
public class CustomerService  {
	
	//private CustomerBean customer;
	
	/* (non-Javadoc)
	 * @see com.db.ws.pace.server.CustomerIntf#getCustomer(int)
	 */
	public CustomerBean getCustomer(int customerNo) {
		// TODO Auto-generated method stub
		CustomerBean cust = new CustomerBean();
		cust.setCustomerNo(customerNo);
		cust.setCustomerFirstName("Kiran Kumar");
		cust.setCustomreLastName("MV");
		return cust;
	}

}

---------===========------------

I tried implementing this using jibx, 
i generated binding.xml file by giving input of both beans.
then generated binding.xsd.
used binding.xsd as input and generated wsdl.

I then performed the following:

======================
1. Generate the binding.xml file
-----------------------
 C:\Projects\JibxMathProject\bin>java -jar
C:\KiranKumarMV\softzz\Axis2\jibx_1_1_3\jibx\lib\jibx-genbinding.jar
com.db.ws
.pace.shared.CustomerBean com.db.ws.pace.shared.Address
Running binding generator version 0.2

2. Generate the binding.xsd file
-------------------------
C:\Projects\JibxMathProject\bin>java -jar
C:\KiranKumarMV\softzz\Axis2\jibx_1_1_3\jibx\lib\jibx-genschema.jar
binding.xm
l
Running schema generator version 0.2
Wrote schema binding.xsd for default namespace

3. Generate the wsdl file
---------------------------

C:\Projects\JibxMathProject\bin>java2wsdl -cn
com.db.ws.pace.server.CustomerService -stn binding.xsd -cp .
Using AXIS2_HOME:   C:\KiranKumarMV\softzz\Axis2\axis2-1.1.1
Using JAVA_HOME:    C:\Program Files\j2sdk1.4.2_02\
[JAM] Warning: You are running under a pre-1.5 JDK.  JSR175-style source
annotations will not be available

4. Generate java from wsdl:
-------------------------------

C:\Projects\JibxMathProject\bin>wsdl2java -uri CustomerService.wsdl -p
customer.service.jibx -d jibx -s -ss -sd -ssi  -o
 build/service -Ebindingfile binding.xml
Using AXIS2_HOME:   C:\KiranKumarMV\softzz\Axis2\axis2-1.1.1
Using JAVA_HOME:    C:\Program Files\j2sdk1.4.2_02\
Exception in thread "main"
org.apache.axis2.wsdl.codegen.CodeGenerationException:
java.lang.RuntimeException: No mapping
 defined for element {binding.xsd}getCustomer
        at
org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)
Caused by: java.lang.RuntimeException: No mapping defined for element
{binding.xsd}getCustomer
        at
org.apache.axis2.jibx.CodeGenerationUtility.mapQName(CodeGenerationUtility.java:928)
        at
org.apache.axis2.jibx.CodeGenerationUtility.mapMessage(CodeGenerationUtility.java:914)
        at
org.apache.axis2.jibx.CodeGenerationUtility.engage(CodeGenerationUtility.java:384)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.apache.axis2.wsdl.codegen.extension.JiBXExtension.engage(JiBXExtension.java:74)
        at
org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:177)
        ... 2 more
C:\Projects\JibxMathProject\bin>

Here i  get error, please suggest or help me from here.

Your help towards this will be highly appreciable.

Thanks,
Kiran Kumar MV.
http://www.nabble.com/file/5988/binding.xml binding.xml 
http://www.nabble.com/file/5989/binding.xsd binding.xsd 
http://www.nabble.com/file/5990/CustomerService.wsdl CustomerService.wsdl 
-- 
View this message in context: http://www.nabble.com/-AXIS2--How-to-transfer-XML-from-Axis2-Webservice-to-any-client-%28.net-java-*-any-client%29-tf3132844.html#a8680435
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org