473,699 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in getting attributes from webservice to servlet when d return type String[]

13 New Member
I made a Webservice Operation whose return type is STRING [] Following is the code

Expand|Select|Wrap|Line Numbers
  1. @WebMethod(operationName = "authorize") public String [] authorize(@WebParam(name = "Username") String Username) 
  2.   CAuthorization CA = new CAuthorization(); 
  3.   String [] Result= null; 
  4.   try {
  5.     Result = CA.CheckAuthorization(Username); 
  6.   } catch (SQLException ex) {
  7.     Logger.getLogger(WS_Authentication.class.getName()).log(Level.SEVERE, null, ex); 
  8.   }
  9.   return Result;
  10. }
And then i made a Servlet The code of the servlet thing is :
Expand|Select|Wrap|Line Numbers
  1. try { // Call Web Service Operation
  2.   java.lang.String result = null;
  3.   result =  port.authorize(Username);
  4.   out.println("Result = "+result);
  5. } catch (Exception ex) {
  6.   // TODO handle custom exceptions here
  7. }
Problem is in my WEbservice Code in RETURN STATEMENT i have attributes of any table and i want to take these attributes to servlet so that i can see them on my front end but what im getting here is the only the LAST ATTRIBUTE

I WANT TO HAVE ALL THE ATTRIBUTES HERE ; so that i can print them in my front end

HELP!
Dec 9 '09 #1
8 3147
chaarmann
785 Recognized Expert Contributor
The authorize-method interface is defined to pass an array of strings (all attributes) back, but you are only assigning a single String (one attribute) for the return value.
"... public String [] authorize(..." --> "..String result = port.authorize( ..."

Solution:
"..String[] resultArray = port.authorize( ..."

Please be so kind and don't shout in your answer, my ears are still ringing and my eyes are tingling. There is a (B)old-button on the top, please use it.
Dec 9 '09 #2
Sundhas
13 New Member
Hey thanks for the reply
i tried this too what u sugested already but actually it doen't let me it says " That Result is STRING [] and port.authorize (... is SIMPLE string...

any other way to do it in your mind?

what i did i converted STRING [] into string separated with ", " in webservices so that i can get the attributes on servlet... But its not the cool way i want to know how do we get STRING [] in servlet..
Dec 9 '09 #3
chaarmann
785 Recognized Expert Contributor
Sorry, I don't know much about webservices, but can you return other objects than simple strings?
If yes then you can try with Vector() or ArrayList()
Dec 9 '09 #4
Sundhas
13 New Member
Right! Yes we can use ArrayList ( )
Thankyou :)
Dec 9 '09 #5
deepakdsharma
2 New Member
Hi Sundhas,

Did u solve the problem.
Give you give some example how u finally did it?

Please help!!

Thnx
Mar 28 '10 #6
Sundhas
13 New Member
This is the way u can handle Webservice Operation of String Return type

@WebMethod(oper ationName = "authorize" )
public String authorize(@WebP aram(name = "Username")
String Username) {

CAuthorization CA = new CAuthorization( );
StringBuffer result = new StringBuffer();
try {
if (CA.CheckAuthor ization(Usernam e).length > 0) {
result.append(C A.CheckAuthoriz ation(Username)[0]);
for (int i = 1; i < CA.CheckAuthori zation(Username ).length; i++) {
result.append(" ,");
result.append(C A.CheckAuthoriz ation(Username)[i]);
}
}
} catch (SQLException ex) {
Logger.getLogge r(WS_Authentica tion.class.getN ame()).log(Leve l.SEVERE, null, ex);
}
//TODO write your implementation code here:
return result.toString ();
}
Mar 28 '10 #7
deepakdsharma
2 New Member
Thanks for reply. Basically i wanted to query database and send the multiple rows to client. Java web service should return multiple rows and columns.
Mar 29 '10 #8
Sundhas
13 New Member
Yes.. Previously i was trying to do so but somehow wasnt able to.. So i figured this out.
Sorry can't help more

Regards
Sundhas
Mar 29 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9702
by: Johnnie | last post by:
Hello, I am trying to submit a request object to a server (not local), using a servlet. When given a ZIP code this particular server is supposed to return xml with the city/state/areacode etc... The instructions for the server are: :HTTP GET The following is a sample HTTP GET request and response.
1
2919
by: citnamor | last post by:
Hello, I'm trying to access a webservice which runs on our SOAP Server (Apache Tomcat) with Windows 2000 Advanced Server. I simply added the webreference local copy of wsdl file into dotNet Application using dotNet's "Add Web Reference" option. I am trying to execute a function using pieces of code as follows; ---------------------------------- WebReference.MyService kkAPI = new WebReference.MyService();
16
4915
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
5
19594
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
1
2859
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive types and of more elaborate classes implementing IXmlSerializable. The resulting WSDL file for the webservice has two separate schemas in its <types> sections, and the client proxy (generated with wsdl.exe) is missing the definitions of the...
0
2385
by: TraceyAnnison | last post by:
I wonder if you can help me - I'm new to this, and working in a project that has already been configured to work with Axis. We have a Java project built with the Spring framework, in order to provide webservices for access via SOAP. As I understand it (ie not very well!) Axis works to accept these SOAP messages from the client and transform them into calls on our Java methods, and do the reverse with the responses - cool! Which is excellent,...
3
19041
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field on my webpage. I get back that my readyState is 4 and my status is 200 and status text is "OK", but my responseText is always empty. Both on FireFox and IE7, so it must be something I'm doing (wrong). I've also set up an IFRAME to redirect the...
2
2616
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in another screen. All of this has to be done with java servlets. I think there's something I don't see and it's wrong. My problem is that anything I enter in the search bar appears as a result in the results page, even if there's not such a name in...
2
2789
raveendrabikkina
by: raveendrabikkina | last post by:
03/17 15:45:40 error Error creating form bean of class epost.form.BpUploadForm java.lang.InstantiationException: epost.form.BpUploadForm at java.lang.Class.newInstance0(Class.java:291) at java.lang.Class.newInstance(Class.java:259) at org.apache.03/17 15:45:03 info Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true 03/17 15:45:03 info Initializing,...
0
8620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6536
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.