Changes for page Web Services-Problems
Last modified by Francis Labrie on 2007/10/15 16:21
From version 4.1
edited by smmccraw
on 2007/07/08 09:46
on 2007/07/08 09:46
Change comment:
There is no comment for this version
To version 3.1
edited by Pascal Robert
on 2007/09/03 19:32
on 2007/09/03 19:32
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-Problems1 +Web Services-Problems - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. smmccraw1 +XWiki.probert - Content
-
... ... @@ -1,8 +1,8 @@ 1 -= Problems 1 += Problems = 2 2 3 3 This section describes some problems and bugs that sometimes occur when using //WebObjects Web Services//. 4 4 5 -== DirectToWebService can't return a WSDL with secure HTTPS references in it 5 +== DirectToWebService can't return a WSDL with secure HTTPS references in it == 6 6 7 7 **Authors:** Francis Labrie 8 8 ... ... @@ -10,61 +10,51 @@ 10 10 11 11 **Bug reference:** rdar:~/~/3546304 12 12 13 -=== Problem: 13 +=== Problem: === 14 14 15 -A //DirectToWebService// defined Web Services doesn't return correct WSDL document, even if the correct procedure (see Secure Web Services) is followed. So only classes oriented Web Services manually registered with the {{code}}com.webobjects.appserver.WOWebServiceRegistrar{{/code}} class seems to generate a correct WSDL.15 +A //DirectToWebService// defined Web Services doesn't return correct WSDL document, even if the correct procedure (see Secure Web Services) is followed. So only classes oriented Web Services manually registered with the 16 16 17 - === Solution: ===17 +{{code}} 18 18 19 - Darel Lee from Apple told me that right now, the dynamicWSDL generation is not exposed to developers so there currently isn't a clean solution to performthis.Oneworkaround is to hardcoderules (of {{code}}com.webobjects.directtoweb.Assignment{{/code}} type) with the {{code}}serviceLocationURL{{/code}} key forach operation that you want to use secureHTTPS references. Forinstance:19 +com.webobjects.appserver.WOWebServiceRegistrar 20 20 21 -{{ panel}}21 +{{/code}} 22 22 23 - {code}23 +class seems to generate a correct WSDL. 24 24 25 - {{/panel}}25 +=== Solution: === 26 26 27 - ((operationName="anOperation")and (serviceName="Service"))->27 +Darel Lee from Apple told me that right now, the dynamic WSDL generation is not exposed to developers so there currently isn't a clean solution to perform this. One workaround is to hardcode rules (ofcom.webobjects.directtoweb.Assignment type) with the serviceLocationURL key for each operation that you want to use secure HTTPS references. For instance: 28 28 29 -{{panel}} 30 - 31 - serviceLocationURL="https://host.net/cgi-bin/Service.woa/ws/Service" 32 - 33 -{{/panel}} 34 - 35 35 {{code}} 36 36 31 +((operationName="anOperation") and (serviceName="Service")) -> 32 + serviceLocationURL="https://host.net/cgi-bin/Service.woa/ws/Service" 37 37 38 -If you need all operation to be called using the secure protocol, you can also define a more generic rule like this one: 39 - 40 - 41 41 {{/code}} 42 42 43 -(serviceName="Service") -> 44 - serviceLocationURL="https:~/~/host.net/cgi-bin/Service.woa/ws/Service" 36 +If you need all operation to be called using the secure protocol, you can also define a more generic rule like this one: 45 45 46 46 {{code}} 47 47 40 +(serviceName="Service") -> 41 + serviceLocationURL="https://host.net/cgi-bin/Service.woa/ws/Service" 48 48 49 -h2. SOAP serializers and deserializers registered with 50 50 {{/code}} 51 51 52 -WOWebServiceRegistrar{{code}} class doesn't appear in the WSDL schema 53 - *Authors:* Francis Labrie 45 +=== SOAP serializers and deserializers registered with WOWebServiceRegistrar class doesn't appear in the WSDL schema === 54 54 55 - *Affected products:* _WebObjects_ 5.2.x, 5.3.x 47 +Authors:Francis Labrie 48 +Affected products:WebObjects5.2.x, 5.3.x 49 +Bug reference:rdar:~/~/3546330 56 56 57 - *Bugreference:*rdar://354633051 +==== Problem: ==== 58 58 53 +Custom SOAP serializers and deserializers registered to Web Services with com.webobjects.appserver.WOWebServiceRegistrar class are never added to the types / schema definition of the WSDL. The only type definitions shown are the following: 59 59 60 -h3. Problem: 61 -Custom SOAP serializers and deserializers registered to Web Services with {{/code}}com.webobjects.appserver.WOWebServiceRegistrar{{code}} class are never added to the types / schema definition of the WSDL. The only type definitions shown are the following: 55 +{{code}} 62 62 63 -{{/code}} 64 - 65 -{{panel}} 66 - 67 - <types> 57 +<types> 68 68 <schema targetNamespace="http://lang.java/" xmlns:soapenc= 69 69 "http://schemas.xmlsoap.org/soap/encoding/" xmlns= 70 70 "http://www.w3.org/2001/XMLSchema"> ... ... @@ -80,7 +80,7 @@ 80 80 </complexContent> 81 81 </complexType> 82 82 <element name="ArrayOf_xsd_any" nillable="true" type= 83 - "lang:ArrayOf_xsd_any"/> 73 + "lang:ArrayOf_xsd_any"/> 84 84 </schema> 85 85 <schema targetNamespace="http://www.apple.com/webobjects/ 86 86 webservices/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/ ... ... @@ -89,7 +89,7 @@ 89 89 <element name="entityName" type="xsd:string"/> 90 90 <element name="primaryKeys" type="lang:ArrayOf_xsd_any"/> 91 91 </complexType> 92 - <element name="EOGlobalID" type="tns:EOGlobalID"/> 82 + <element name="EOGlobalID" type="tns:EOGlobalID"/> 93 93 <complexType name="EOEnterpriseObject"> 94 94 <element name="entityName" type="xsd:string"/> 95 95 <element name="globalID" type="webobjects:EOGlobalID"/> ... ... @@ -98,153 +98,137 @@ 98 98 </schema> 99 99 </types> 100 100 101 -{{/ panel}}91 +{{/code}} 102 102 103 - {{code}}93 +==== Solution: ==== 104 104 105 - 106 -h3. Solution: 107 107 I don't know any dynamic workaround right now... But a static and complete WSDL can be shared through a direct action. It's not very handy though... 108 108 109 -h2. DirectToWebService can't return a WSDL with custom namespace and definitions name in it 110 - *Authors:* Francis Labrie 97 +=== DirectToWebService can't return a WSDL with custom namespace and definitions name in it === 111 111 112 - *Affected products:* _WebObjects_ 5.2.x, 5.3.x 99 +Authors:Francis Labrie 100 +Affected products:WebObjects5.2.x, 5.3.x 101 +Bug reference: 113 113 114 - *Bugreference:*103 +==== Problem: ==== 115 115 105 +A //DirectToWebService// defined Web Services can't return a WSDL with custom values for properties like namespaces and definitions name. Worse, the generated namespace can even contains WebObjects application instance number or the wrong hostname. 116 116 117 -h3. Problem: 118 -A _DirectToWebService_ defined Web Services can't return a WSDL with custom values for properties like namespaces and definitions name. Worse, the generated namespace can even contains WebObjects application instance number or the wrong hostname. 107 +==== Solution: ==== 119 119 120 -h3. Solution: 121 -Base on a tips from Darel Lee, I've found in the 122 -{{/code}} 109 +Base on a tips from Darel Lee, I've found in the com.webobjects.webservices.generation.//private.WOWSDLTemplate class some extras key definitions read from the user.d2wmodel DirectToWebService rule file. For instance~:// 123 123 124 -com.webobjects.webservices.generation.//private.WOWSDLTemplate{{code}} class some extras key definitions read from the user.d2wmodel DirectToWebService rule file. For instance: 111 +* **serviceLocationURL:** a key that allow the setting of the location URL for an operation. This is usefull if you need your WebServices to be reached using a secure HTTPS reference; 112 +* **WSDLDefinitionName:** a key that allow the definitions name change. So instead of having "ServiceNameDefinition", you can set this value; 113 +* **WSDLTargetNamespace:** a key that allow the namespace change. This is the most usefull: you can avoid dynamic generation depending on WebObjects HTTP Adaptor? with this. 125 125 126 -* *serviceLocationURL:* a key that allow the setting of the location URL for an operation. This is usefull if you need your WebServices to be reached using a secure HTTPS reference; 127 -* *WSDLDefinitionName:* a key that allow the definitions name change. So instead of having "ServiceNameDefinition", you can set this value; 128 -* *WSDLTargetNamespace:* a key that allow the namespace change. This is the most usefull: you can avoid dynamic generation depending on WebObjects HTTP Adaptor? with this. 129 - 130 130 Here is an example of rule definition changing the above values: 131 131 132 -{{/code}} 133 -(serviceName="Service") -> 134 - WSDLTargetNamespace="https:~/~/host.net/cgi-bin/Service.woa/ws/Service" 135 -(serviceName="Service") -> 136 - WSDLDefinitionName="AnotherDefinition" 137 -((operationName="anOperation") and (serviceName="Service")) -> 138 - serviceLocationURL="https:~/~/host.net/cgi-bin/Service.woa/ws/Service"// 139 - 140 140 {{code}} 141 141 142 -h2. WOWebServiceClient class can't connect to a server that requires an authentication (WO 5.2.x, Bug ID 3568441) 143 - *Authors:* Francis Labrie 119 +(se(serviceName="Service") -> 120 + WSDLTargetNamespace="https://host.net/cgi-bin/Service.woa/ws/Service" 121 +(serviceName="Service") -> 122 + WSDLDefinitionName="AnotherDefinition" 123 +((operationName="anOperation") and (serviceName="Service")) -> 124 + serviceLocationURL="https://host.net/cgi-bin/Service.woa/ws/Service" 144 144 145 - *Affected products:* _WebObjects_ 5.2.x, 5.3.x126 +{{/code}} 146 146 147 - *Bug reference:*rdar://3568441128 +=== WOWebServiceClient class can't connect to a server that requires an authentication (WO 5.2.x, Bug ID 3568441) === 148 148 130 +Authors:Francis Labrie 131 +Affected products:WebObjects5.2.x, 5.3.x 132 +Bug reference:rdar:~/~/3568441 149 149 150 -h3. Problem: 151 -The 152 -{{/code}} 134 +==== Problem: ==== 153 153 154 -com.webobjects.webservices.client.WOWebServiceClient {{code}} class can't connect to a server that requires a Basic HTTP Authentication despite the fact this class offers a way to register a security delegate (see{{/code}}setSecurityDelegateForServiceNamed(Object, String){{code}}instance method).136 +The com.webobjects.webservices.client.WOWebServiceClientclass can't connect to a server that requires a Basic HTTP Authentication despite the fact this class offers a way to register a security delegate (see setSecurityDelegateForServiceNamed(Object, String) instance method). 155 155 156 -Normally, the {{/code}}processClientRequest(MessageContext){{code}}delegate method (see{{/code}}com.webobjects.webservices.support.WOSecurityDelegate{{code}}interface documentation) would allow an easy way to set a username and a password to the message context. But there is a problem related to the design of the class: to register a security delegate, the{{/code}}WOWebServiceClient{{code}} class has to fetch the Web Services Definition Language (WSDL) XML document. But to get access to this WSDL, an authentication header must be set. This is the classic chicken and egg problem...138 +Normally, the processClientRequest(MessageContext) delegate method (see com.webobjects.webservices.support.WOSecurityDelegateinterface documentation) would allow an easy way to set a username and a password to the message context. But there is a problem related to the design of the class: to register a security delegate, the WOWebServiceClientclass has to fetch the Web Services Definition Language (WSDL) XML document. But to get access to this WSDL, an authentication header must be set. This is the classic chicken and egg problem... 157 157 158 -h3. Solution: 159 -The best would be to add a default method to {{/code}}WOWebServiceClient{{code}} class to register a default security delegate that is not related to a service name before the class fetch the WSDL. But unfortunately, all key methods that would allow this kind of behavior change are privates, so subclassing is not a solution... 140 +==== Solution: ==== 160 160 161 - But aworkaround isstillpossible:142 +The best would be to add a default method to WOWebServiceClientclass to register a default security delegate that is not related to a service name before the class fetch the WSDL. But unfortunately, all key methods that would allow this kind of behavior change are privates, so subclassing is not a solution... 162 162 163 -# Fetch the WSDL document yourself and store it to the local filesystem, using the java.net.URL instance and setting up the Basic HTTP Authentication header field of the {{/code}}java.net.URLConnection{{code}} yourself; 164 -# Instanciate another {{/code}}java.net.URL{{code}} class that refer to the local WSDL document file; 165 -# Instanciate the {{/code}}com.webobjects.webservices.client.WOWebServiceClient<>code> class using the file URL; 144 +But a workaround is still possible: 166 166 146 +1. Fetch the WSDL document yourself and store it to the local filesystem, using the java.net.URL instance and setting up the Basic HTTP Authentication header field of the java.net.URLConnection yourself; 147 +1. Instanciate another java.net.URL class that refer to the local WSDL document file; 148 +1. Instanciate the com.webobjects.webservices.client.WOWebServiceClient<>code> class using the file URL; 167 167 1. Set for each service a security delegate that will add the proper credential information for the Basic HTTP Authentication. 168 168 169 169 That's it. It looks like a big hack, but it works... 170 170 171 -~=== Web Services can't return a WSDL with secure HTTPS references specifying port other than the default 443 === 172 -~: '''Authors:''' Francis Labrie<br> 173 -~: '''Affected products:''' ''WebObjects'' 5.2.x, 5.3.x<br> 174 -~: '''Bug reference:''' rdar:~/~/4196417<br> 153 +=== Web Services can't return a WSDL with secure HTTPS references specifying port other than the default 443 === 175 175 176 -~==== Problem: ==== 155 +Authors:Francis Labrie 156 +Affected products:WebObjects5.2.x, 5.3.x 157 +Bug reference:rdar:~/~/4196417 158 + 159 +==== Problem: ==== 160 + 177 177 HTTPS protocol references can be published in Web Services WSDL. But unfortunately, WebObjects seems to ignore ports other than the default 443. 178 178 179 -This problem is related to the bad way <code>com.webobjects.appserver.WORequest{{code}}build the URL prefix: if the protocol is secure and no port (i.e. 0) is set when calling the{{/code}}//completeURLPrefix(StringBuffer,boolean,int){{code}}method, the port will always be 443. Unfortunately, Web Services{{/code}}com.webobjects.appserver.//private.WOWebService{{code}} class seems to call this method without setting the port number.163 +This problem is related to the bad waycom.webobjects.appserver.WORequestbuild the URL prefix: if the protocol is secure and no port (i.e. 0) is set when calling the//completeURLPrefix(StringBuffer,boolean,int)method, the port will always be 443. Unfortunately, Web Servicescom.webobjects.appserver.//private.WOWebServiceclass seems to call this method without setting the port number. 180 180 181 -h3. Solution: 182 -To work around this bug, you can subclass the {{/code}}com.webobjects.appserver.WORequest{{code}} class like this: 165 +==== Solution: ==== 183 183 184 -{{/code}} 185 -package com.smoguli.appserver; 167 +To work around this bug, you can subclass the com.webobjects.appserver.WORequest class like this: 186 186 169 +{{code}} 170 + 171 + package com.smoguli.appserver; 172 + 187 187 import com.webobjects.appserver.WORequest; 188 188 import com.webobjects.foundation.NSData; 189 189 import com.webobjects.foundation.NSDictionary; 190 190 191 -/ 192 - 193 -{{panel}} 194 - 177 +/** 195 195 * This class provide fixed {@link com.webobjects.appserver.WORequest} methods. 196 196 * To use it, just overload the {@link com.webobjects.appserver.WOApplication. 197 - * createRequest(String,String,String,NSDictionary,NSData,NSDictionary)} method 180 + * createRequest(String,String,String,NSDictionary,NSData,NSDictionary)} method 198 198 * to instanciate this class instead. 199 199 * 200 - * @author 183 + * @author Francis Labrie <francis.labrie at smoguli.com> 201 201 */ 202 - 203 -{{/panel}} 204 - 205 205 public class WOFixedRequest extends WORequest { 206 206 207 - / 187 + /** 188 + * @see com.webobjects.appserver.WORequest#WORequest(String,String,String, 189 + * NSDictionary,NSData,NSDictionary) 190 + */ 191 + public WOFixedRequest(String method, String url, String httpVersion, NSDictionary headers, NSData content, NSDictionary info) { 192 + super(method, url, httpVersion, headers, content, info); 193 + } // WOFixedRequest 208 208 209 -* @see com.webobjects.appserver.WORequest#WORequest(String,String,String, 210 -* NSDictionary,NSData,NSDictionary) 211 - **/ 212 - public WOFixedRequest(String method, String url, String httpVersion, NSDictionary headers, NSData content, NSDictionary info) { 213 - super(method, url, httpVersion, headers, content, info); 214 - } ~/~/ WOFixedRequest** 195 + /** 196 + * This method builds the URL prefix into the <code>urlPrefix</code> buffer 197 + * with the appropriate protocol (<code>http</code> or <code>https</code>) 198 + * and the right TCP port. But unlike the {@link com.webobjects.appserver. 199 + * WORequest#_completeURLPrefix(StringBuffer,boolean,int} method, it 200 + * supports secure HTTP protocol (<code>https</code>) with port other than 201 + * <code>443</code>, even if the <code>port</code> parameter is set 202 + * <code>0</code>. 203 + * 204 + * @param urlPrefix the buffer that receives the contructed URL. 205 + * @param isSecure a flag indicating if the protocol is secure. 206 + * @param port the port number. 207 + */ 208 + public void _completeURLPrefix(StringBuffer urlPrefix, boolean isSecure, int port) { 209 + if(isSecure && (port == 0)) { 210 + String serverPort; 215 215 216 - / 212 + serverPort = _serverPort(); 213 + if((serverPort != null) && !serverPort.equals("443")) { 214 + try { 215 + port = Integer.parseInt(serverPort); 216 + } catch(NumberFormatException exception) {} // catch 217 + } // if 218 + } // if 217 217 218 -* This method builds the URL prefix into the <code>urlPrefix</code> buffer 219 -* with the appropriate protocol (<code>http</code> or <code>https</code>) 220 -* and the right TCP port. But unlike the {@link com.webobjects.appserver. 221 -* WORequest#//completeURLPrefix(StringBuffer,boolean,int} method, it // 222 -* supports secure HTTP protocol (<code>https</code>) with port other than 223 -* <code>443</code>, even if the <code>port</code> parameter is set 224 -* <code>0</code>. 225 - 226 -* @param urlPrefix the buffer that receives the contructed URL. 227 -* @param isSecure a flag indicating if the protocol is secure. 228 -* @param port the port number. 229 - **/ 230 - public void //completeURLPrefix(StringBuffer urlPrefix, boolean isSecure, int port) { 231 - if(isSecure && (port == 0)) { 232 - String serverPort;//** 220 + super._completeURLPrefix(urlPrefix, isSecure, port); 221 + } // _completeURLPrefix 222 +} // WOFixedRequest 233 233 234 - serverPort = //serverPort(); 235 - if((serverPort [[image:= null) &&]]serverPort.equals("443")) { 236 - try { 237 - port = Integer.parseInt(serverPort); 238 - } catch(NumberFormatException exception) {} ~/~/ catch 239 - } ~/~/ if 240 - } ~/~/ if// 241 - 242 - super.//completeURLPrefix(urlPrefix, isSecure, port); 243 - } ~/~/ //completeURLPrefix 244 -} ~/~/ WOFixedRequest 245 - 246 -{{code}} 247 - 248 - 249 -Category:WebObjects 250 250 {{/code}}