Author: amilas
Date: Thu Jan 6 08:46:39 2011
New Revision: 1055792
URL: http://svn.apache.org/viewvc?rev=1055792&view=rev
Log:
supporting redirect urls for jaxbri
Modified:
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
Modified:
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=1055792&r1=1055791&r2=1055792&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
(original)
+++
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
Thu Jan 6 08:46:39 2011
@@ -48,6 +48,8 @@ import javax.xml.namespace.QName;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -86,6 +88,21 @@ public class CodeGenerationEngine {
(CommandLineOption)allOptions.
get(CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION);
wsdlUri = option.getOptionValue();
+
+ // the redirected urls gives problems in code generation some
times with jaxbri
+ // eg. https://www.paypal.com/wsdl/PayPalSvc.wsdl
+ // if there is a redirect url better to find it and use.
+ if (wsdlUri.startsWith("http")) {
+ URL url = new URL(wsdlUri);
+ HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
+ connection.setInstanceFollowRedirects(false);
+ connection.getResponseCode();
+ String newLocation = connection.getHeaderField("Location");
+ if (newLocation != null){
+ wsdlUri = newLocation;
+ }
+ }
+
configuration = new CodeGenConfiguration(allOptions);