Changes for page Web Services-Controlling WSDL Service Location
Last modified by Pascal Robert on 2007/09/03 19:24
From version 1.1
edited by smmccraw
on 2007/07/08 10:35
on 2007/07/08 10:35
Change comment:
There is no comment for this version
To version 3.1
edited by Pascal Robert
on 2007/09/03 19:24
on 2007/09/03 19:24
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Programming__WebObjects-WebServices-Controlling WSDL Service Location1 +Web Services-Controlling WSDL Service Location - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. smmccraw1 +XWiki.probert - Content
-
... ... @@ -1,10 +1,10 @@ 1 -This documentation was written by Andrew Lindesay (http: ~/~/www.lindesay.co.nz) in 2006 as part of supported code in the LEWOStuff framework, but this material has been transcribed here. It was written around the time of WebObjects 5.2 and 5.3 on the 1.4 JVM.1 +This documentation was written by Andrew Lindesay ([[http://www.lindesay.co.nz]]) in 2006 as part of supported code in the LEWOStuff framework, but this material has been transcribed here. It was written around the time of WebObjects 5.2 and 5.3 on the 1.4 JVM. 2 2 3 3 AXIS provides a number of handlers for ultimately executing the WS. This generally works in the WebObjects environment out of the box. However, in the case of a servlet deployment, the URLs are manipulated by the servlet container so they look something like this. 4 4 5 5 {{panel}} 6 6 7 - <font color="red">;jsessionid=abc.i1</font>?wsdl7 +...ects/FOO.woa/ws/FooService;jsessionid=abc.i1?wsdl 8 8 9 9 {{/panel}} 10 10 ... ... @@ -11,13 +11,12 @@ 11 11 If a client starts a session on a WS invocation then you want all subsequent requests to return to this same servlet container (Here we assume a redundant deployment where there are a number of servlet containers.) where the session resides. However the servlet-container's HTTP adaptor typically only knows this by looking at the modified URL. Unfortunately, the default WSDL generated by AXIS would have a section like this. 12 12 13 13 {{code}} 14 + 14 14 ... 15 15 <wsdl:service name="FooService"> 16 -{panel} 17 17 <wsdl:port name="FooService" binding="impl:FooService SoapBinding"> 18 18 <wsdlsoap:address location="http://foo.co.nz/FOO/WebObjects/FOO.woa/ws/FooService"/> 19 19 </wsdl:port> 20 -{panel} 21 21 </wsdl:service> 22 22 ... 23 23 ... ... @@ -26,15 +26,14 @@ 26 26 A WSDL like this does not contain the modified URL caused by the context having a session in the location for the service. The example handler //LEWOWebServicesWSDLLocationHandler// below which is supplied in LEWOStuff will correct the location supplied in the WSDL to contain the session information. To install this handler for use in WebObjects, locate the //server.wsdd// file within your project and modify the following section so that it appears as follows. 27 27 28 28 {{code}} 28 + 29 29 ... 30 30 <transport name="http"> 31 -{panel} 32 32 <requestFlow> 33 33 <handler type="HTTPActionHandler"/> 34 34 <handler type="URLMapper"/> 35 35 <handler type="java:nz.co.lindesay.common.webobjects.LEWOWebServicesWSDLLocationHandler"/> 36 36 </requestFlow> 37 -{panel} 38 38 </transport> 39 39 40 40 {{/code}} ... ... @@ -58,17 +58,13 @@ 58 58 following conditions are met: 59 59 60 60 * Redistributions of source code must retain the above 61 -{panel} 62 62 copyright notice, this list of conditions and the 63 63 following disclaimer. 64 -{panel} 65 65 66 66 * Redistributions in binary form must reproduce the above 67 -{panel} 68 68 copyright notice, this list of conditions and the 69 69 following disclaimer in the documentation and/or other 70 70 materials provided with the distribution. 71 -{panel} 72 72 73 73 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 74 74 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ... ... @@ -94,12 +94,11 @@ 94 94 import org.apache.axis.*; 95 95 96 96 /** 97 -{panel} 98 98 * <P>This class is an AXIS request handler that is designed to 99 99 * manipulate the outbound WSDL that is generated for a 100 100 * request. The manipulation undertaken here is to modify the 101 101 * location of the actual service. The reason for doing this is 102 - * that if you have a web service deployed into a servlet 95 + * that if you have a web service deployed into a servlet 103 103 * container as a WO application, the session'ed URLs can look 104 104 * a bit like this.</P> 105 105 * ... ... @@ -116,12 +116,11 @@ 116 116 * handler list as the last item in the list. This should be the 117 117 * request flow in the HTTP transport section.</P> 118 118 * 119 - * <P><TT> <handler type="java:nz.co.lindesay.common.webobjects.LEWOWebServicesWSDLLocationHandler"/></TT></P>112 + * <P><TT><handler type="java:nz.co.lindesay.common.webobjects.LEWOWebServicesWSDLLocationHandler"/></TT></P> 120 120 * 121 121 * <P>This should also work with the "<I>wotaskd</I>" deployment 122 122 * style as well.</P> 123 123 */ 124 -{panel} 125 125 126 126 public class LEWOWebServicesWSDLLocationHandler extends org.apache.axis.handlers.BasicHandler 127 127 { ... ... @@ -128,91 +128,87 @@ 128 128 129 129 // -------------------------------------------------------------- 130 130 131 - 123 + public LEWOWebServicesWSDLLocationHandler() { super(); } 132 132 133 133 // -------------------------------------------------------------- 134 134 135 135 /** 136 -{panel} 137 137 * <P>This is the AXIS hook where we can manipulate the outbound 138 138 * WSDL.</P> 139 139 */ 140 -{panel} 141 141 142 - 143 - 144 - 145 - 146 - 147 - 148 - 149 - 150 - 151 - 152 - 153 - 154 - 155 - 156 - 157 - 158 - 159 - 160 - 161 - 162 - 163 - 164 - 165 - 166 - 167 - 168 - 169 - 170 - 171 - 132 + public void generateWSDL(MessageContext msgContext) throws AxisFault 133 + { 134 + WOContext context = WOWebServiceUtilities.currentWOContext(); 135 + WORequest request = context.request(); 136 + String host = LEWOHelper.getExternalHostnameFromInboundRequest(request); 137 + int port = LEWOHelper.getExternalPortFromInboundRequest(request); 138 + int appi = request.applicationNumber(); 139 + 140 + if((null==host)||(0==host.length())) 141 + throw new IllegalStateException("the host cannot be determined from the inbound request."); 142 + 143 + if(context.hasSession()) 144 + context.session(); 145 + 146 + StringBuffer sb = new StringBuffer(); 147 + 148 + sb.append("http://"); 149 + sb.append(host); 150 + 151 + if(-1!=port) 152 + { 153 + sb.append(":"); 154 + sb.append(Integer.toString(port)); 155 + } 156 + 157 + String path = context.urlWithRequestHandlerKey( 158 + request.requestHandlerKey(), 159 + request.requestHandlerPath(), 160 + null); 161 + 172 172 // Unless the context has a session, we can't get it to come back 173 173 // to a specific instance, but in the case of a 'wotaskd' deploy, 174 174 // there is no way to specify the session for a WSDL request, so 175 175 // we'll do a nasty hack to make this work. 176 - 177 - if((-1!=appi)&&(!context.hasSession())) 178 - { 179 - String webServiceRequestHandlerKey = WOApplication.application().webServiceRequestHandlerKey(); 180 - String startPath = request.adaptorPrefix()+"/"+request.applicationName()+".woa"; // ''/cgi-bin/WebObjects/Foo.woa'' 181 - 182 - if(!path.startsWith(startPath)) 183 - throw new IllegalStateException("The path '"+path+"' should have started with '"+startPath+"'"); 184 184 185 - if(path.startsWith(startPath+"/"+webServiceRequestHandlerKey)) 186 - { 187 - StringBuffer pathSB = new StringBuffer(); 188 - 189 - pathSB.append(startPath); 190 - pathSB.append("/"); 191 - pathSB.append(Integer.toString(appi)); 192 - pathSB.append(path.substring(startPath.length())); 193 - 194 - path = pathSB.toString(); 195 - } 196 - } 197 - 198 - sb.append(path); 199 - 200 - msgContext.setProperty(MessageContext.WSDLGEN_SERV_LOC_URL,sb.toString()); 201 - } 167 + if((-1!=appi)&&(!context.hasSession())) 168 + { 169 + String webServiceRequestHandlerKey = WOApplication.application().webServiceRequestHandlerKey(); 170 + String startPath = request.adaptorPrefix()+"/"+request.applicationName()+".woa"; // ''/cgi-bin/WebObjects/Foo.woa'' 202 202 172 + if(!path.startsWith(startPath)) 173 + throw new IllegalStateException("The path '"+path+"' should have started with '"+startPath+"'"); 174 + 175 + if(path.startsWith(startPath+"/"+webServiceRequestHandlerKey)) 176 + { 177 + StringBuffer pathSB = new StringBuffer(); 178 + 179 + pathSB.append(startPath); 180 + pathSB.append("/"); 181 + pathSB.append(Integer.toString(appi)); 182 + pathSB.append(path.substring(startPath.length())); 183 + 184 + path = pathSB.toString(); 185 + } 186 + } 187 + 188 + sb.append(path); 189 + 190 + msgContext.setProperty(MessageContext.WSDLGEN_SERV_LOC_URL,sb.toString()); 191 + } 192 + 203 203 // -------------------------------------------------------------- 204 204 205 205 /** 206 -{panel} 207 207 * <P>Basically there is nothing to do here because we are not 208 208 * interested in messing with the request/response cycle - rather 209 209 * we want only to manipulate the WSDL.</P> 210 210 */ 211 -{panel} 212 212 213 - 214 - 215 - 201 + public void invoke(MessageContext msgContext) throws AxisFault 202 + { 203 + } 216 216 217 217 // -------------------------------------------------------------- 218 218