haitham raik

Greenhorn
+ Follow
since Aug 08, 2004
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by haitham raik

I have just finished a number of SCJWSD topics and now I am preparing myself to read about the web services securiry, anybody can help me how to start and what is the good tutorials and books that I can use to study it? is the xml security required to understand the ws security?

thanks in advance.
Dear Peer Reynders

you have said "Now use the ServletEndpointContext.getMessageContext() and set a property with MessageContext.setProperty to store the address." what do you mean by now and now relative to what and where can I use ServletEndpointContext.getMessageContext() to set the property. and another thing the getMessageContext method is not a static method.

can you please explain more?

thanks in advance.
sorry every body the spaces has been removed and the figure has been damaged but the main idea from the figure is to say that the client side uses the stub which in turn sends a soap message to the JAX-RPC servlet. this servlet has the ability to read the SOAP message and make a method invokation on the web service endpoint:

client side -> stub -> JAX-RPC servlet -> JSE

Regards
Dear all

I guess that I found a way to get the remote IP address for a JSE (Java service endpoint) but this way is not useful if you are using the session bean as a webservice. this way depends on the idea that the JSE is wrapped by a JAX-RPC servlet as the following figure:


{client side} {server side}
============================= =================================
= ---------- ------ = = ----------- -------- =
= - Client - uses -stub- = soap = - JAX RPC - delegate - JSE - =
= - side - ------> - - = req = - servlet - ------> - - =
= ---------- ------ = ----> = ----------- -------- =
============================= =================================

by adding a javax.servlet.Filter to the JAX-RPC servlet I have an instance of the ServletRequest which I can use to get the remote address as the following:
public MyFilter implememts Filter{
...
public void doFilter(ServletRequest req, ServletResponse rs, FiterChain c){
String ipAddr = req.getRemoteAddr();
...
}
...
}

then add this address to the session as the following:
public MyFilter implememts Filter{
...
public void doFilter(ServletRequest req, ServletResponse rs, FiterChain c){
String ipAddr = req.getRemoteAddr();
request.getSession().setAttribute("ipAddress", ipAddr);
...
}
...
}

in the web service class implements the javax.xml.rpc.server.ServiceLifecycle interface which has two methods:
1) init(java.lang.Object context)
2) destroy()

in the init method the Object param is an instance of javax.xml.rpc.server.ServletEndpointContext which has a method called getHttpSession() which can be used to get the session instance that has been created in the filter. so by getting the session instance we can get the ipaddress attribute. as the following:

public class WebService1_Impl implements WebService1_Interface, ServiceLifecycle{
ServletEndpointContext ctx;
public void init(Object obj){
ctx = (ServletEndpointContext) obj;
}

public void theServiceMethod(){
String ipAddr=(String)ctx.getHttpSession().getAttribute("ipAddress");
System.out.println(ipAddr);
}

public void destroy(){
}
}

Regards
Dear all

I have another question. are any of the following topics are required for the exam:
1) SwA (SOAP messages with Attachments).
2) RPC/Encoded.
3) DTD.
4) XML Schema Regular Expressions.
5) using SAAJ to create a soap message with attachement.
Thank you. but I am using the IBM WSAD not AXIS. and I am looking to make my projects vendor-independent.
Hi all

I have created a web service and I want the remote address of the request to log it in a file. any body can help me to get the remote address.

thanks
Hello everybody

I am just a little confused what is the proper tool that I can use to study the web services certificate. I mean when I was reading the SCWCD I have used the tomcat because it forced me to write every thing by myself (servlet, web.xml, etc). so, are there any tool that can be used to create a simple exmples without help?

thanks in advance.
I think the registration here means that the servlet is declared in the web.xml as the following:
<web-app>
...
<servlet>
<servlet-name>servlet name</servlet-name>
<servlet-class>servlet.name</servlet-class>
</servlet>
17 years ago
to solve the pagination problem you may use a request parameter for page number(e.g., pageNo).
when the user enter the URL to visit the page for the first time. the page number parameter will be not exist so you will send the first 14 records. if the user clicked on the next button send the ?pageNo=1 Parameter with the request URL. if you received the pageNo=1 as a parameter you will send the 2nd 14 records.
17 years ago
there are two solutions:
- the first one: ask the user about his country then display the appropriate page depending on his answer.

- the second solution is using the following code:
Locale userLocale = request.getLocale();
if(userLocale.getCountry().equalsIgnoreCase("US")){
//display US Page
}else{
//display the other page
}

but remeber that the getLocale() method may return null or return the server Locale depending on the Servlet Container Implementation. so, you can not depend on the second solution.
17 years ago

Originally posted by ravindranath konduru:
Hello
iam having problems with context path in server.xml file.i dont know where to change the context path(either in context root or context examples one).can somebody send me the details and full server.xml file.
i wrote a servlet called GreetingServlet and placed it in folder greeting ,placed it in c:/program files/java/tomcat 4.1/webapps folder.
thanks for your help in advance
tagore


-----------------------------------------
there are a number of conditions that you have to follow to build a new web application.
to create a new web application follow the following steps:
1. create a new folder under the webapps folder for the tomcat (e.g., greeting folder)
2. create a subfolder in greeting folder called WEB-INF(required).
3. create a subfolder in WEB-INF directory called classes(required) and set any classes that you have created in this folder or any subfolder(for example com/GreetingServlet.class).
4. under the WEB-INF folder create a new file called web.xml(required).
5. in the web.xml file add the following text.
<web-app>
<servlet>
<servlet-name>greetingSer</servlet-name>
<servlet-class>com.GreetingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetingSer</servlet-name>
<url-pattern>*.greet</url-pattern>
</servlet-mapping>
</web-app>

6. restart the tomcat.
7. open the internet browser and print the following URL: http://localhost:8080/greeting/hello.greet and click Enter

now the output of your servlet will be displayed on your browser.
17 years ago