Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Yogs Kumar

Greenhorn
+ Follow
since Apr 07, 2014
Yogs likes ...
Mac Eclipse IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Yogs Kumar

Please help fellow Ranchers, your guidance will be highly appreciated.
5 years ago
Hello Everyone,

I have been working with IBM RAD to generate a simple web services client using a WSDL. The client generation goes fine and all the classes get added to the custom package I specified.I was able to write a test program to run the client code and get the response from the service. However my problem is with a class being generated which is part of the package at client.

My service name is MessagePrintService and inside the package at client I see a class which is MessagePrintServiceProxy.java and it is as follows:



However this class is not being used anywhere and when I deleted the class,i was still able to run the client code without any issues.I tried researching on the net but couldn't find an explantion for this class.

Can someone please explain why this class is generated ,what is its use? and why is it in the package even though its not being used.

Thanks a lot for your time
5 years ago

Frits Walraven wrote:The only disadvantage you have when studying RESTEasy for the WSD exam is for coding Web Service client. The exam topic "Create a web service client for a RESTful web service" assumes you have some basic knowledge coding a Jersey JAX-RS client.

For the exam you can stick to Jersey 1.x (as it conforms to JAX-RS v1.1). If you read the Jersey 2.x manual you willl learn a lot of stuff that is not part of the exam (as it conforms to JAX-RS 2.0).

Here is the link to the Jersey 1.18 manual.

Regards,
Frits


Thanks for your response Frits,that link to the guide is very useful,thanks again

Himai Minh wrote:For this exam, focus on Jersey API. Someone mentioned in this forum that reading the latest Jersey User Guide (version 2.8) from Chapter 1 -5 will help.
But it is still ok to practice with RestEasy. The basic concepts of both RestEasy and Jersey are more or less the same.



Thanks for your response Himai

Ulf Dittmer wrote:Well ... I'll let the experts answer that. The Exam Topics (which I'm sure you've read by now, short as they are) mention "Create a RESTful web service in a servlet container", amongst other topics. That could conceivably involve deployment steps that are implementation-dependent.



Ok Ulf, thanks for your response

Ulf Dittmer wrote:Jersey is the RI. Since the objective is JAX-RS, though, I would imagine that any conforming implementation would be fine.


Thanks for your response Ulf, so if i whose to study the RESTEasy RI,i wont be in any disadvantage for the certification correct?, what i mean to ask is will there be any questions in the certification specific to Jersey RI?
Hello Everyone,

I am preparing for the OCEJWSD certification.When it comes to JAX-RS which is the Reference Implementation that is better to study from a certification point of view.It is RESTEasy or Jersey?.

Thanks,
Yogs
Hello Everyone,

I am trying to understand what exactly is a Namespace Context and request your help in this regard.

I am trying to write a simple REST service using Provider/Dispatcher model and using XPATH to traverse the request Source.
There is a statement which sets the NameSpaceContext for the XPATH object.I understand the concept of namespace which is done in order to avoid XML name collision and for clear identification of XML elements.

What exactly is this namespace context?Why is it necessary for both client and service to use the same namespace URI for the service to work correctly,also if client and service needs to use the same namespace URI,who provides the format or the URI to the client in cases of REST services.

6 years ago

Ulf Dittmer wrote:I can't think of a good reason why they wouldn't. Those frameworks do so much for you, and are so easy to use, that it'd be a waste of time to reinvent the wheel, IMO.



Hello Ulf, thanks for the response, coming back to my original question, can you please provide me some pointers on how i can handle this POST request
6 years ago

Ulf Dittmer wrote:My first question would be: why are you not using a REST framework like Jersey? Implementing all those low-level parts is a lot of work that other folks have already done for you.



Hello Ulf,

I am working through the examples in Web services up and running and this is the second example in that book where all oher CRUD operations are implemented.So i am still not using any of the frameworks you mentioned.

Thinking from a production scenario,will all applications use one or the other framework of REST services?.
6 years ago
Hello Everyone,

I am trying to write a simple REST service which writes a new team of players into a text file every time the client is executed.The client is sending the POST request as follows:
private void sendPostRequest() {
byte [] team_to_add;
Player hibbert = new Player("Hibbert", "Roy Hibbert");
Player paul = new Player("Paul", "Paul George");
Player west = new Player("West", "David West");
List<Player> mb = new ArrayList<Player>();
mb.add(hibbert);
mb.add(paul);
mb.add(west);
Team Pacers = new Team("Indiana_Pacers",mb);
// TODO Auto-generated method stub
XMLEncoder enc;
try {
enc = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("team_to_add.txt")));
enc.writeObject(Pacers);
enc.close();
}
catch(Exception e)
{

}
HttpURLConnection PostConn = get_connection(endpoint,"POST"); //method defined in the class to get a HTTP connection.
System.out.println(PostConn.getRequestMethod());
try {
PostConn.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(PostConn.getOutputStream());
String cwd = System.getProperty ("user.dir");
String sep = System.getProperty ("file.separator");
int len = (int) new File(cwd+sep+"team_to_add.txt").length();
team_to_add=new byte[len];
new FileInputStream(cwd+sep+"team_to_add.txt").read(team_to_add);
wr.write(team_to_add);
wr.flush();
wr.close();
System.out.println(PostConn.getResponseCode());

In the REST service I am obtaining the Message Context object.

Can someone help me to figure out how i can get access to the body of the POST message being sent from the client.

Thanks in advance
6 years ago

Luan Cestari wrote:Is there any error message? I was thinking a little bit more about this problem, i think i was wrong (after looking more the WSDL/XML schema and amazon docs), maybe what it is really missing the Signature parameter.

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/TheXMLMessageforanItemSearchSOAPRequest.html



Hello Luan thanks for looking into this

I have two points to add:

1.Yes these services needs signature and i am passing the required access key and secret key as run time arguments to the class.On the links you mentioned they had also told about the X.509 certificates.I created and installed those certificates in the mac keystore but no luck with the results.

2.I configured tcpmon to see what is the response xml i was getting the strange thing i noticed was that tcpmon is recording only the first request to get WSDL but i do NOT see a request going for this Item search operation.I am not sure why a request is not being sent or if there is some problem with my tcpmon in capturing the request.

Again thanks for your time!!!
6 years ago

Luan Cestari wrote:I think the problem is this line:
Holder<OperationRequest> operation_request = null;

You must define the operation, which in this case would be the ItemSearch I think.



Hello Luan Cestari,

That parameter is defined as an output parameter in the web service.The last two parameters are output parameters.So do you think i should assigning the value ItemSearch to that operation_request parameter.

Thanks
6 years ago
Hello Everyone,
I am working on examples from Web Services up and running .I am currently trying to execute the following client against amazon web service.The class runs fine without any issues but no books are returned in the resultset,any idea what might be the problem

Here are the steps i followed:
1.I used the wsimport command to get the client classes:
wsimport -keep -p awsClient \ http://ecs.amazonaws.com/AWSECommerceService/AWSECommerceService.wsdl

2.Following is my client class:

import awsClient.AWSECommerceService;
import awsClient.AWSECommerceServicePortType;
import awsClient.ItemSearchRequest;
import awsClient.ItemSearch;
import awsClient.Items;
import awsClient.Item;
import awsClient.OperationRequest;
import awsClient.SearchResultsMap;
import awsClient.AwsHandlerResolver;
import javax.xml.ws.Holder;
import javax.xml.ws.handler.HandlerResolver;

import java.util.List;
import java.util.ArrayList;

class AmazonClientW {
public static void main(String[ ] args) {
if (args.length < 1) {
System.err.println("Usage: java AmazonClientW <access key>");
return;
}
final String access_key = args[0];
// Construct a service object to get the port object.
AWSECommerceService service = new AWSECommerceService();
service.setHandlerResolver(new AwsHandlerResolver("**********************"));
AWSECommerceServicePortType port = service.getAWSECommerceServicePort();
// Construct an empty request object and then add details.
ItemSearchRequest request = new ItemSearchRequest();
request.setSearchIndex("Books");
request.setKeywords("physics");
ItemSearch search = new ItemSearch();
search.getRequest().add(request);
search.setAWSAccessKeyId(access_key);
Holder<OperationRequest> operation_request = null;
Holder<List<Items>> items = new Holder<List<Items>>();
port.itemSearch(search.getMarketplaceDomain(), search.getAWSAccessKeyId(),search.getAssociateTag(), search.getXMLEscaping(), search.getValidate(), search.getShared(), search.getRequest(), operation_request, items);

// Unpack the response to print the book titles.

Items retval = items.value.get(0); // first and only Items element
List<Item> item_list = retval.getItem();
// list of Item subelements
for (Item item : item_list)
{
System.out.println("Inside for!!!");
System.out.println(item.getItemAttributes().getTitle());
}
}
}

Can someone please help me as to what might be the reason for not getting any books in the result.
6 years ago
Hello Everyone,

I am working on examples from Web Services up and running.I am currently using eclipse IDE.Is there a way we can use the wsgen and wsimport tools inside the eclipse IDE.

Thanks
6 years ago