For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 16 replies, 4 voices, and was last updated 18 years, 2 months ago by
rkm258.
-
AuthorPosts
-
rkm258MemberHi,
Developing web services was made really easy here when compared to what i did using weblogic ant tasks.
My problem is regarding the use of COMPLEX TYPES LIKE OBJECTS OF A CLASS FOR SERVICE OPERATIONS, FOR USING THEM OR RETURNING THEM. Is there any thing more needed to be done other than what has been specified at
http://myeclipseide.com/enterpriseworkbench/help/index.jsp for web services development from bottum up.I’am getting validation errors on using objects of a class as return type.
PLEASE HELP ME FOR SOME DOCUMENTATION IN THIS REGARD.
thanks ram
June 19, 2007 at 11:12 am #271729
Riyad KallaMemberRam,
Unfortunately i don’t understand the question… do you have some concrete examples of the issue?June 19, 2007 at 11:43 am #271733
rkm258MemberHi,
I have a Class say Office that has all the properties filled up by the service operation and returned by it like below
The Class object returned by the Service Operation is
public class Office
{
public int contact;
public String deptname;
}The service Impl is like
public class OfficeSetupHierServiceImpl implements IOfficeSetupHierService {
public Office getDetails(int deptid)
{
//get the office details populated in the Office object and return it.
}
}Where the OfficeSetupHierServiceImp is the service implementation and IOfficeSetupHierService is the service interface.
I did this following the simple webservice development from bottum up approach as given in the help http://myeclipseide.com/enterpriseworkbench/help/index.jsp but there is validation error on using it with web service explorer.
Since i’am not using any collections and other complex types i did not put any aegis mapping files, assuming that defauls bidings will be used.
Also help me regarding documentation for using complex types,lists,collections and class objects in service operations as parameter or return types, in the same way as this sample code does.
I’am not sure if any thing else has to be done when using types other than the basic types.
Thanks for reply
looking forward
ramJune 19, 2007 at 1:46 pm #271754
Riyad KallaMemberRam,
What are the validation errors you get?June 19, 2007 at 2:40 pm #271765
rkm258MemberHi,
Below is the error I’am getting:
Error resolving component ‘ns1:Office’. It was detected that ‘ns1:Office’ is in
namespace ‘http://office.hr.com’, but components from this namespace are not
referenceable from schema document ‘http://localhost:8080/ELMSServ/services/OfficeSet’The WSDL is
<?xml version=”1.0″ encoding=”UTF-8″?>
<wsdl:definitions targetNamespace=”http://service.hr.com” xmlns:tns=”http://service.hr.com” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope” xmlns:ns1=”http://office.hr.com” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding” xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>
<wsdl:types>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema” attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://service.hr.com”>
<xsd:element name=”getDetails”>
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs=”1″ minOccurs=”1″ name=”in0″ type=”xsd:int”/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”getDetailsResponse”>
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs=”1″ minOccurs=”1″ name=”out” nillable=”true” type=”ns1:Office”/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema” attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://office.hr.com”>
<xsd:complexType name=”Office”/>
</xsd:schema>
</wsdl:types>
<wsdl:message name=”getDetailsResponse”>
<wsdl:part name=”parameters” element=”tns:getDetailsResponse”>
</wsdl:part>
</wsdl:message>
<wsdl:message name=”getDetailsRequest”>
<wsdl:part name=”parameters” element=”tns:getDetails”>
</wsdl:part>
</wsdl:message>
<wsdl:portType name=”OfficeSetupHierServicePortType”>
<wsdl:operation name=”getDetails”>
<wsdl:input name=”getDetailsRequest” message=”tns:getDetailsRequest”>
</wsdl:input>
<wsdl:output name=”getDetailsResponse” message=”tns:getDetailsResponse”>
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=”OfficeSetupHierServiceHttpBinding” type=”tns:OfficeSetupHierServicePortType”>
<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/>
<wsdl:operation name=”getDetails”>
<wsdlsoap:operation soapAction=””/>
<wsdl:input name=”getDetailsRequest”>
<wsdlsoap:body use=”literal”/>
</wsdl:input>
<wsdl:output name=”getDetailsResponse”>
<wsdlsoap:body use=”literal”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=”OfficeSetupHierService”>
<wsdl:port name=”OfficeSetupHierServiceHttpPort” binding=”tns:OfficeSetupHierServiceHttpBinding”>
<wsdlsoap:address location=”http://localhost:8080/ELMSServ/services/OfficeSetupHierService”/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>ALSO HERE ARE THE OFFICE CLASS, SERVICE IMPL AND SERVICE INTERFACE
package com.hr.office;
public class Office {
public int deptid;
public String ownership;
}————————————————————————————–
package com.hr.service;
//Generated by MyEclipseimport java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import com.hr.office.Office;public class OfficeSetupHierServiceImpl implements IOfficeSetupHierService {
private Connection con;
private Statement stm;public OfficeSetupHierServiceImpl()
{
try
{
con=DriverManager.getConnection(“jdbc:microsoft:sqlserver://10.10.60.50:1433;DatabaseName=OfficeSetup”,”WebTrans_App”,”ChangeMe”);
stm=con.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public Office getDetails(int deptid)
{
ResultSet rs;
try
{
rs=stm.executeQuery(“SELECT office_gl_Dep_id,orgz_ownership_desc_txt FROM dbo.vw_office_setup_hier WHERE office_gl_Dep_id=”+deptid);
rs.next();
//return(rs.getString(“orgz_ownership_desc_txt”));
Office o=new Office();
o.deptid=rs.getInt(“office_gl_Dep_id”);
o.ownership=rs.getString(“orgz_ownership_desc_txt”);
return o;
}
catch(Exception e)
{
e.printStackTrace();
return null;
}}
/*public String getService(int deptid)
{}*/
}
—————————————————————————
package com.hr.service;
//Generated by MyEclipse
import com.hr.office.Office;public interface IOfficeSetupHierService {
public Office getDetails(int deptid);
//public String getService(int deptid);
}———————————————————————————————————
I HAD EVEN PUT THE MAPPING AEGIS XML FOR SERVICE INTERFACE AS I WAS NOT SURE WHERE THE PROBLEM WAS<?xml version=”1.0″ encoding=”UTF-8″?>
<mappings>
<mapping>
<method name=”getDetails”>
<return-type componentType=”com.hr.office.Office”/>
<parameter index=”0″ class=”int”/>
</method>
</mapping>
</mappings>June 19, 2007 at 3:11 pm #271772
rkm258MemberAbove are the WSDL,Service Interface,Service Impl and a bean Office that i used.
I tried generating the web service client using the web service client generation option but there seems to be these validation errors
are making the Office class to be empty.
—————————————————————————————————
I also tried running the service using the client code within the service project and not using the Web service client generation
like below, where the Service Interface and the Office bean class are in the classpathpublic static void main(String[] args) {
// TODO Auto-generated method stub
Service srvcModel = new
ObjectServiceFactory().create(IOfficeSetupHierService.class);
XFireProxyFactory factory =
new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String helloWorldURL =
“http://localhost:8080/ELMSServ/services/OfficeSetupHierService”;
try {
IOfficeSetupHierService srvc = (IOfficeSetupHierService)factory.create(srvcModel, helloWorldURL);
//String result = srvc.example(“hello world”);
Office o=srvc.getDetails(1008);
System.out.println(o.deptid);
System.out.println(o.ownership);
//System.out.print(result);
} catch (Exception e) {
e.printStackTrace();
}}
In this case the service is getting executed but the client is not receiving the values of the properties.June 19, 2007 at 4:01 pm #271773
rkm258MemberI’AM SORRY I MISSED A PORTION OF THE VALIDATION ERROR.
THE EXACT VALIDATION ERROR IS AS BELOW
Error resolving component ‘ns1:Office’. It was detected that ‘ns1:Office’ is in
namespace ‘http://office.hr.com’, but components from this namespace are not
referenceable from schema document ‘http://localhost:8080/ELMSServ/services/OfficeSetHierService?WSDL.
If this is the incorrect namespace, perhaps the prefix of ‘ns1:Office’ needs to be changed.
If this is the correct namespace then an appropriate import tag should be added to
http://localhost:8080/ELMSServ/services/OfficeSetHierService?WSDL.June 19, 2007 at 4:25 pm #271775
rkm258MemberWell after putting the Office under same namespace as tns:Office, i.e putting the Office in the same package as the service, below is the
error i’am getting for validation.WS-I: A problem occured while running the WS-I WSDL conformance check: org.eclipse.wst.wsi.internal.analyzer.WSIAnalyzerException:
The WS-I Test Assertion Document(TAD) document was either not found or could not be processed.
The WSDL Analyzer was unable to validate the given WSDL File.AS A NOTE I WOULD LIKE TO REMIND THAT WHEN THE CLIENT IS RUN IN THE SAME PROJECT WORKSPACE AS THE SERVICE I.E WITHOUT USING THE WEB SERVICE CLIENT GENERATION THE SERVER WEB SERVICE SEEMS TO BE RUNNING BUT THE OBJECT OBTAINED AT THE CLIENT IS NOT CONTAINING ANY PROPERTY VALUES IN IT.
Waiting for ur help
ThanksJune 19, 2007 at 4:36 pm #271778
rkm258MemberLet me know if u need anything else. I need to solve this problem to move ahead in my work.
Thanks for your help in advance
June 19, 2007 at 5:36 pm #271783
Riyad KallaMemberRam,
This is a bit over my head, I’ve sent your issue ot someone on the dev team to take a look at when they had a chance.June 19, 2007 at 5:51 pm #271784
Brian FernandesModeratorRam,
A few questions:
1) What version of MyEclipse are you using?
2) Can you please paste your services.xml file here?
3) You mentioned that you were generating a bottom up webservice (code first). Later you pasted a WSDL file – where did you get this file? Just so that we are on the same page, could you please restate your current approach for generating the services; are you generating them from a WSDL or from a java classes? If the former is true, then could you please paste the latest version of the WSDL file here?
Sorry for the inconvenience caused, but it is hard to get a grip your current position with so many posts.
June 20, 2007 at 9:32 am #271806
rkm258MemberHi Brain,
Donot be sorry, I will restate everything i have done again clearly.
——————————————————————
Requirement
My requirement is to return a Class Object (Office in my case) whose properties (varaibles) are filled with some values and returned by the service operation.
——————————————————————
Version
Below are the installation details of the my eclipse
*** Date:
Wednesday, June 20, 2007 8:56:35 AM CDT** System properties:
OS=Windows2003
OS version=5.2
Java version=1.5.0_12*** MyEclipse details:
MyEclipse Enterprise Workbench
Version: 5.5.1 GA
Build id: 20070521-5.5.1-GA*** Eclipse details:
Eclipse SDKVersion: 3.2.2
Build id: M20070212-1330Eclipse Platform
Version: 3.2.2.r322_v20070119-RQghndJN8IM0MsK
Build id: M20070212-1330Eclipse Java Development Tools
Version: 3.2.2.r322_v20070104-R4CR0Znkvtfjv9-
Build id: M20070212-1330Eclipse Graphical Editing Framework
Version: 3.2.0.v20060626
Build id: 20070208-1315Eclipse RCP
Version: 3.2.2.r322_v20070104-8pcviKVqd8J7C1U
Build id: M20070212-1330Eclipse Plug-in Development Environment
Version: 3.2.1.r321_v20060823-6vYLLdQ3Nk8DrFG
Build id: M20070212-1330Eclipse Project SDK
Version: 3.2.2.r322_v20070104-dCGKm0Ln38lm-8s
Build id: M20070212-1330Eclipse Graphical Editing Framework
Version: 3.2.2.v20070208
Build id: 20070208-1315Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
E:\eclipse\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
1210_6c
-vm
C:\Program Files\Java\jdk1.5.0_12\bin\javaw.exe———————————————————————-
Procedure For developing the services by bottum up approach:
1. First i created the web service project.
2. Created a Web service with Service Interface and Service Impl as below
//The Service Interface
package com.hr.service;
//Generated by MyEclipse
import com.hr.service.Office;public interface IOfficeSetupHierService {
public Office getDetails(int deptid);
}//The service Implementation
package com.hr.service;
//Generated by MyEclipseimport java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import com.hr.service.Office;public class OfficeSetupHierServiceImpl implements IOfficeSetupHierService {
private Connection con;
private Statement stm;
public OfficeSetupHierServiceImpl()
{
try
{
con=DriverManager.getConnection(“URL”);
stm=con.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public Office getDetails(int deptid)
{
ResultSet rs;
try
{
rs=stm.executeQuery(“SELECT office_gl_Dep_id,orgz_ownership_desc_txt FROM dbo.vw_office_setup_hier WHERE office_gl_Dep_id=”+deptid);
rs.next();
//return(rs.getString(“orgz_ownership_desc_txt”));
Office o=new Office();
o.deptid=rs.getInt(“office_gl_Dep_id”);
o.ownership=rs.getString(“orgz_ownership_desc_txt”);System.out.println(“GOT INTO OFFICE “+o.deptid+” “+o.ownership);
return o;
}
catch(Exception e)
{
// System.out.println(“ERROR”);
e.printStackTrace();
return null;
}}
}——————————————————————————
The Office Class that i returned from the service Implemation class is as below
package com.hr.service;
public class Office {
public int deptid;
public String ownership;
}———————————————————————————-
The Wsdl that was generated is as below. I cannot see the WSDL file as it might have been auto generated on the fly but by browsing
to http://localhost:8080/ELMSServ/services/OfficeSetupHierService?wsdl, below is the WSDL generated<?xml version=”1.0″ encoding=”UTF-8″?>
<wsdl:definitions targetNamespace=”http://service.hr.com” xmlns:tns=”http://service.hr.com” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding” xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>
<wsdl:types>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema” attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://service.hr.com”>
<xsd:element name=”getDetails”>
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs=”1″ minOccurs=”1″ name=”in0″ type=”xsd:int”/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name=”Office”/>
<xsd:element name=”getDetailsResponse”>
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs=”1″ minOccurs=”1″ name=”out” nillable=”true” type=”tns:Office”/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name=”getDetailsResponse”>
<wsdl:part name=”parameters” element=”tns:getDetailsResponse”>
</wsdl:part>
</wsdl:message>
<wsdl:message name=”getDetailsRequest”>
<wsdl:part name=”parameters” element=”tns:getDetails”>
</wsdl:part>
</wsdl:message>
<wsdl:portType name=”OfficeSetupHierServicePortType”>
<wsdl:operation name=”getDetails”>
<wsdl:input name=”getDetailsRequest” message=”tns:getDetailsRequest”>
</wsdl:input>
<wsdl:output name=”getDetailsResponse” message=”tns:getDetailsResponse”>
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=”OfficeSetupHierServiceHttpBinding” type=”tns:OfficeSetupHierServicePortType”>
<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/>
<wsdl:operation name=”getDetails”>
<wsdlsoap:operation soapAction=””/>
<wsdl:input name=”getDetailsRequest”>
<wsdlsoap:body use=”literal”/>
</wsdl:input>
<wsdl:output name=”getDetailsResponse”>
<wsdlsoap:body use=”literal”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=”OfficeSetupHierService”>
<wsdl:port name=”OfficeSetupHierServiceHttpPort” binding=”tns:OfficeSetupHierServiceHttpBinding”>
<wsdlsoap:address location=”http://localhost:8080/ELMSServ/services/OfficeSetupHierService”/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>——————————————————————————————–
Client code : I used two ways to write the client
1. Test Client within the same project as the service and thus without using the web service client generator.
IN THIS CASE WHAT I OBSERVED WAS THAT THE SERVICE WAS RUNNING BUT THE OFFICE OBJECT I RETURNED AND OBTAINED AT THE CLIENT WAS NOT CONTAINING ANY PROPERTY (VARIABLE) VALUES IN IT.
THE PROBLEM IS I THINK IN REGARD TO THE MAPPING FOR THIS OFFICE TYPE CLASS. IS THERE A WAY I CAN SEE THE SOAP MESSAGES GOING UNDER.
package com.client;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.XFireFactory;
import com.hr.service.IOfficeSetupHierService;
import com.hr.service.Office;
public class Client {/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Service srvcModel = new
ObjectServiceFactory().create(IOfficeSetupHierService.class);
XFireProxyFactory factory =
new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String helloWorldURL =
“http://localhost:8080/ELMSServ/services/OfficeSetupHierService”;
try {
IOfficeSetupHierService srvc = (IOfficeSetupHierService)factory.create(srvcModel, helloWorldURL);
//String result = srvc.example(“hello world”);
Office o=srvc.getDetails(1008);
System.out.println(o.deptid);
System.out.println(o.ownership);
//System.out.print(result);
} catch (Exception e) {
e.printStackTrace();
}2. The second approach i used was regarding the web service client genrator option
In this case the client classes are not created properly due to the below validation error.WS-I: A problem occured while running the WS-I WSDL conformance check: org.eclipse.wst.wsi.internal.analyzer.WSIAnalyzerException:
The WS-I Test Assertion Document(TAD) document was either not found or could not be processed.
The WSDL Analyzer was unable to validate the given WSDL File.——————————————————————————
I even wrote the aegis mapping files as below for the service interface and my Office bean and put them in the same folder as the classes
//mapping for the Office class
<?xml version=”1.0″ encoding=”UTF-8″?>
<mappings>
<mapping>
<property name=”deptid” class=”int”/>
<property name=”ownership” componentType=”java.lang.String”/>
</mapping>
</mappings>//Mapping for the service interface
<?xml version=”1.0″ encoding=”UTF-8″?>
<mappings xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://xfire.codehaus.org/schemas/1.0/mapping.xsd”>
<mapping>
<method name=”getDetails”>
<return-type componentType=”com.hr.service.Office”/>
<parameter index=”0″ class=”int”/>
</method>
</mapping>
</mappings>
——————————————————————————-The services.xml file is below
<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://xfire.codehaus.org/config/1.0″><service>
<name>OfficeSetupHierService</name>
<serviceClass>
com.hr.service.IOfficeSetupHierService
</serviceClass>
<implementationClass>
com.hr.service.OfficeSetupHierServiceImpl
</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service></beans>——————————————————————————-
My concern:The client that i have written without using the web service client genrator, that is within the same project space as the service
should atleast run correctly as the service is running and returning the object. I’am not sure if the mapping for this Office type was good enough.ALSO LET ME KNOW IF THERE IS ANY DOCUMENTATION ON USING OR RETURNING CLASS OBJECTS,COLLECTIONS,LISTS AND MAP FROM SERVICE OPERATIONS THAT I CAN LOOK AT.
——————————————————————–Looking forward for your reply
Thanks
RamJune 20, 2007 at 11:25 am #271813
rkm258MemberHi,
IT SEEMS I SOLVED THE PROBLEM.
Anyway can you let me know what to do when a Collection,Hashmap or some other complex types are used.
If exists, can anyone give me the links to these resoureces.Thanks.
RamJune 20, 2007 at 3:38 pm #271840
Riyad KallaMemberRam,
Please let us know how you solved the issue incase others run into the same problem.Also I don’t have any tips for you when working with Collection types… try checking the XFire docs or forums for specifics (we are outside the realm of my understanding of Web Services unfortunately)
June 22, 2007 at 11:27 am #271971
rkm258MemberHi,
I’am sorry i did not post the solution. Having not been through the XFire entirely,I did a small mistake in understading the usage of it’s default binding.
The XFire uses default binding of Aegis that maps XML to POJO. So having used a Class object in the Service operation, the Class should be in POJO style like that of Hibernate, that is setters and getters.
Also on using Arrays,Array of objects and objects in general the aegis.xml file need not be defined. But on using Collections like Map the aegis.xml file has to be defined as below for the corresponding class or service, where componenttype is the package path to the Class.
<mappings xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://xfire.codehaus.org/schemas/1.0/mapping.xsd”>
<mapping>
<method name=”getMap”>
<return-type mappedName=”OfficeMap” keyType=”java.lang.String” componentType=”com.hr.service.Office”/>
</method>
</mapping>
</mappings>This aegis.xml file should be named as <Classname>.aegis.xml and placed in the same folder as the class.Also it has to be defined for the Service Interface and any other Supporting Classses that might have been used for some complex types like collections.
Several other controlling features of the mappings thus the SOAP messages can be seen at the XFire site.
At last i would like to say that using myeclipse has really helped me in reducing my coding time and it is very useful as well.
The only problem is the amount of memory it requires. I get out of heap in using it some times.Thanks
Ram -
AuthorPosts