You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/08/30 21:37:27 UTC
svn commit: r438600 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
Author: dims
Date: Wed Aug 30 12:37:27 2006
New Revision: 438600
URL: http://svn.apache.org/viewvc?rev=438600&view=rev
Log:
- Prevent NPE if types section is missing
- if getElementName is null try getTypeName
- if the service section is missing, pick the first binding and make up a name for the service as well
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=438600&r1=438599&r2=438600&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Wed Aug 30 12:37:27 2006
@@ -305,7 +305,7 @@
*/
private Binding findBinding(Definition dif) throws AxisFault {
Map services = dif.getServices();
- Service service;
+ Service service = null;
Binding binding = null;
Port port = null;
if (serviceName != null) {
@@ -318,39 +318,48 @@
if (services.size() > 0) {
//pick the first service - we don't really have a choice here
service = (Service) services.values().toArray()[0];
+ }
+ }
+ if (service != null) {
+ copyExtensibleElements(service.getExtensibilityElements(), dif,
+ axisService, SERVICE);
+ if (portName != null) {
+ port = service.getPort(portName);
+ if (port == null) {
+ throw new AxisFault("No port found for the given name :"
+ + portName);
+ }
} else {
- throw new AxisFault("No service element found in the WSDL");
+ Map ports = service.getPorts();
+ if (ports != null && ports.size() > 0) {
+ //pick the port with the SOAP address as the default port
+ port = findSOAPPort(ports);
+ if (port == null) {
+ //a SOAP port was not found - log a warning
+ // and use the first port in the list
+ log.info("A SOAP port was not found - " +
+ "picking a random port!");
+ port = (Port) ports.values().toArray()[0];
+ }
+ }
}
- }
- copyExtensibleElements(service.getExtensibilityElements(), dif,
- axisService, SERVICE);
- if (portName != null) {
- port = service.getPort(portName);
- if (port == null) {
- throw new AxisFault("No port found for the given name :"
- + portName);
+
+ axisService.setName(service.getQName().getLocalPart());
+
+ if (port != null) {
+ copyExtensibleElements(port.getExtensibilityElements(), dif,
+ axisService, PORT);
+ binding = port.getBinding();
}
} else {
- Map ports = service.getPorts();
- if (ports != null && ports.size() > 0) {
- //pick the port with the SOAP address as the default port
- port = findSOAPPort(ports);
- if (port == null) {
- //a SOAP port was not found - log a warning
- // and use the first port in the list
- log.info("A SOAP port was not found - " +
- "picking a random port!");
- port = (Port) ports.values().toArray()[0];
- }
+ log.info("A service element was not found - " +
+ "picking a random binding!");
+ Collection bindings = dif.getBindings().values();
+ if (bindings == null || bindings.isEmpty()) {
+ throw new AxisFault("No bindings found in wsdl");
}
- }
-
- axisService.setName(service.getQName().getLocalPart());
-
- if (port != null) {
- copyExtensibleElements(port.getExtensibilityElements(), dif,
- axisService, PORT);
- binding = port.getBinding();
+ binding = (Binding) bindings.iterator().next();
+ axisService.setName(binding.getQName().getLocalPart() + "Service");
}
return binding;
}
@@ -597,10 +606,12 @@
if (wsdl4jMessagePart == null) {
throw new WSDLProcessingException("Missing part named \"" + bindingPartsList.get(0) + "\"");
}
- if (wsdl4jMessagePart.getElementName() == null) {
- //this cannot be done - we need to have a
- //element reference
- throw new WSDLProcessingException("Element reference missing for " + bindingPartsList.get(0) + "!" );
+ QName name = wsdl4jMessagePart.getElementName();
+ if (name == null) {
+ name = wsdl4jMessagePart.getTypeName();
+ }
+ if (name == null) {
+ throw new WSDLProcessingException("Element reference / Type name missing for " + bindingPartsList.get(0) + "!" );
}
inMessage.setElementQName(wsdl4jMessagePart.getElementName());
@@ -1363,17 +1374,19 @@
wsdl4jDefinition.getNamespaces().putAll(namespaces);
//copy types
Types t = importedDef.getTypes();
- List typesList = t.getExtensibilityElements();
- for (int j = 0; j < typesList.size(); j++) {
- Types types = wsdl4JDefinition.getTypes();
- if (types == null) {
- types = wsdl4JDefinition.createTypes();
- wsdl4JDefinition.setTypes(types);
+ if(t != null){
+ List typesList = t.getExtensibilityElements();
+ for (int j = 0; j < typesList.size(); j++) {
+ Types types = wsdl4JDefinition.getTypes();
+ if (types == null) {
+ types = wsdl4JDefinition.createTypes();
+ wsdl4JDefinition.setTypes(types);
+ }
+ types
+ .addExtensibilityElement((ExtensibilityElement) typesList
+ .get(j));
+
}
- types
- .addExtensibilityElement((ExtensibilityElement) typesList
- .get(j));
-
}
//add messages
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org