[SoapRMI] Session-like behaviour
Aleksander Slominski
aslom_at_cs.indiana.edu
Fri, 08 Feb 2002 15:57:01 -0500
hi,
i have applied your patch - if possible please check that the updated code in CVS
solves your problem.
thanks,
alek
Index: src/java/soaprmi/port/soaprmi/port/Endpoint.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsoap/java/src/java/soaprmi/port/soaprmi/port/End
point.java,v
retrieving revision 1.1
diff -u -b -r1.1 Endpoint.java
--- Endpoint.java 2001/08/20 00:51:37 1.1
+++ Endpoint.java 2002/02/08 20:52:26
@@ -31,6 +31,16 @@
binding = binding_;
}
+ public String getCookie()
+ {
+ return sCookie;
+ }
+
+ public void setCookie(String sCookie)
+ {
+ this.sCookie = sCookie;
+ }
+
public String getLocation() {
return location;
}
@@ -70,12 +80,14 @@
return "Endpoint" + "["
+"location="+location
+",binding="+binding
+ +",cookie="+sCookie
+"]";
}
private String location; //TOOD URL
private Binding binding;
+ private String sCookie;
}
/*
Index: src/java/soaprmi/soaprpc/soaprmi/soaprpc/HttpConnectionSoapInvocationHand
ler.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsoap/java/src/java/soaprmi/soaprpc/soaprmi/soapr
pc/HttpConnectionSoapInvocationHandler.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpConnectionSoapInvocationHandler.java
--- HttpConnectionSoapInvocationHandler.java 2001/10/30 19:07:44 1.2
+++ HttpConnectionSoapInvocationHandler.java 2002/02/08 20:52:27
@@ -76,6 +76,13 @@
conn.setRequestProperty("SOAPAction", mi.getSoapAction());
//"\""+targetURI + "#" + mi.getMethodRequestName() +"\"");
+ //set cookie
+ String sCookie = epoint.getCookie();
+ if (!"".equals(sCookie) && sCookie != null)
+ {
+ conn.setRequestProperty("Cookie", sCookie);
+ }
+
//conn.connect();
OutputStream out = conn.getOutputStream();
//out.write("hello".getBytes());
@@ -95,15 +102,28 @@
// it takes care of not reading beyond Content-Length
InputStream in = conn.getInputStream();
+
+ //get the cookie:
+ sCookie = conn.getHeaderField("Set-Cookie");
+ if (!"".equals(sCookie) && sCookie != null)
+ {
+ int nIndex = sCookie.indexOf(";");
+ if (nIndex >= 0)
+ {
+ sCookie = sCookie.substring(0, nIndex);
+ }
+ // System.out.println(sCookie);
+ l.finest("received Set-Cookie sCookie = "+sCookie);
+ epoint.setCookie(sCookie);
+ }
String contentType = conn.getContentType();
Pollähne. Ullrich wrote:
> BTW: We got the sessions to work with minor changes. ;-)
> C:\work\xsoap_1_2_8>diff
> src\java\soaprmi\port\soaprmi\port\Endpoint.java Endpoint.java
> 16c16
> < *
> ---
> > *
> 62c62
> < }
> ---
> > }
> 66c66
> < return location.hashCode(); //TODO: ^ binding.hashCode();
> ---
> > return location.hashCode(); //TODO: ^ binding.hashCode();
> 72a73
> > +",cookie="+sCookie
> 75a77,85
> > public String getCookie()
> > {
> > return sCookie;
> > }
> >
> > public void setCookie(String sCookie)
> > {
> > this.sCookie = sCookie;
> > }
> 78a89
> > private String sCookie;
>
> C:\work\xsoap_1_2_8>diff
> src\java\soaprmi\soaprpc\soaprmi\soaprpc\HttpConnectionSoapInvocationHan
> dler.java HttpConnectionSoapInvocationHandler.java
> 54c54
> <
> ---
> >
> 79a80,87
> >
> > //set cookie
> > String sCookie = epoint.getCookie();
> > if (!"".equals(sCookie) && sCookie != null)
> > {
> > conn.setRequestProperty("Cookie", sCookie);
> > }
> >
> 93c101
> <
> ---
> >
> 95a104
> >
> 99a109,121
> > //get the cookie:
> > sCookie = conn.getHeaderField("Set-Cookie");
> > if (!"".equals(sCookie) && sCookie != null)
> > {
> > int nIndex = sCookie.indexOf(";");
> > if (nIndex >= 0)
> > {
> > sCookie = sCookie.substring(0, nIndex);
> > }
> > // System.out.println(sCookie);
> > epoint.setCookie(sCookie);
> > }
> >
> 103c125
> <
> ---
> >
> 107c129
> <
> ---
> >
> 111c133
> <
> ---
> >
> 130c152
> <
> ---
> >
>
> Ullrich.