473,748 Members | 4,804 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 3155
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
9704
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
2923
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
4925
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
19599
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
2862
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
2389
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
19052
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
2618
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
2793
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
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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
9544
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
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
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
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.