Author: keith
Date: Thu Apr 3 04:33:41 2008
New Revision: 15520
Log:
Adding support for both defaulting and explicit control WSDL mode
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
==============================================================================
---
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
(original)
+++
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
Thu Apr 3 04:33:41 2008
@@ -347,7 +347,9 @@
wsRequest.reset();
}
- String wsdlURL = null;
+ String wsdlURL;
+ QName serviceQName = null;
+ String endpointName = null;
switch (arguments.length) {
case 0:
throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
@@ -363,6 +365,31 @@
else
throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
break;
+ case 3:
+ throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ case 4:
+ if (arguments[1] instanceof org.wso2.javascript.xmlimpl.QName)
{
+ org.wso2.javascript.xmlimpl.QName qName =
+ (org.wso2.javascript.xmlimpl.QName) arguments[1];
+ String uri = (String) qName.get("uri", qName);
+ String localName = (String) qName.get("localName", qName);
+ serviceQName = new QName(uri, localName);
+ } else
+ throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ if (arguments[2] instanceof String)
+ endpointName = (String) arguments[2];
+ else
+ throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ if (arguments[3] instanceof Boolean)
+ wsRequest.async = ((Boolean) arguments[3]).booleanValue();
+ else
+ throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ if (arguments[0] instanceof String)
+ wsdlURL = (String) arguments[0];
+ else
+ throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ wsRequest.wsdlMode = true;
+ break;
default:
throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
}
@@ -373,50 +400,34 @@
WSDLReader reader =
WSDLFactory.newInstance().newWSDLReader();
reader.setFeature("javax.wsdl.importDocuments", true);
Definition definition =
reader.readWSDL(getBaseURI(wsdlURL), doc);
- Map services = definition.getServices();
Service service = null;
- for (Iterator iter = services.values().iterator();
iter.hasNext();) {
- service = (Service) iter.next();
- if (service.getPorts().size() > 0) {
- //i.e we have found a service with ports
- break;
- }
- }
- if (service == null) {
- throw Context.reportRuntimeError("The WSDL given does not
contain any services " +
- "that has ports");
- }
- Map ports = service.getPorts();
- Port port;
Port returnPort = null;
- for (Iterator portsIterator = ports.values().iterator();
portsIterator.hasNext();) {
- port = (Port) portsIterator.next();
- List extensibilityElements = port.getExtensibilityElements();
- for (int i = 0; i < extensibilityElements.size(); i++) {
- Object extElement = extensibilityElements.get(i);
- if (extElement instanceof SOAP12Address) {
- // SOAP 1.2 address found - keep this and loop until
http address is found
- returnPort = port;
- String location = ((SOAP12Address)
extElement).getLocationURI().trim();
- if ((location != null) &&
location.startsWith("http:")) {
- // i.e we have found an http port so return from
here
- break;
- }
+ if (serviceQName == null) {
+ Map services = definition.getServices();
+ service = null;
+ for (Iterator iter = services.values().iterator();
iter.hasNext();) {
+ service = (Service) iter.next();
+ if (service.getPorts().size() > 0) {
+ //i.e we have found a service with ports
+ break;
}
}
- }
-
- if (returnPort == null) {
- for (Iterator portsIterator = ports.values().iterator();
portsIterator
- .hasNext();) {
+ if (service == null) {
+ throw Context.reportRuntimeError("The WSDL given does not
contain any services " +
+ "that has ports");
+ }
+ Map ports = service.getPorts();
+ Port port;
+ returnPort = null;
+ for (Iterator portsIterator = ports.values().iterator();
portsIterator.hasNext();) {
port = (Port) portsIterator.next();
List extensibilityElements =
port.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
Object extElement = extensibilityElements.get(i);
- if (extElement instanceof SOAPAddress) {
- // SOAP 1.1 address found - keep this and loop
until http address is found
+ if (extElement instanceof SOAP12Address) {
+ // SOAP 1.2 address found - keep this and loop
until http address is found
returnPort = port;
- String location = ((SOAPAddress)
extElement).getLocationURI().trim();
+ String location = ((SOAP12Address)
extElement).getLocationURI().trim();
if ((location != null) &&
location.startsWith("http:")) {
// i.e we have found an http port so return
from here
break;
@@ -432,11 +443,10 @@
List extensibilityElements =
port.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++)
{
Object extElement = extensibilityElements.get(i);
- if (extElement instanceof HTTPAddress) {
- // HTTP address found - keep this and loop
until http address is found
+ if (extElement instanceof SOAPAddress) {
+ // SOAP 1.1 address found - keep this and loop
until http address is found
returnPort = port;
- String location =
- ((HTTPAddress)
extElement).getLocationURI().trim();
+ String location = ((SOAPAddress)
extElement).getLocationURI().trim();
if ((location != null) &&
location.startsWith("http:")) {
// i.e we have found an http port so
return from here
break;
@@ -444,17 +454,42 @@
}
}
}
+
+ if (returnPort == null) {
+ for (Iterator portsIterator =
ports.values().iterator(); portsIterator
+ .hasNext();) {
+ port = (Port) portsIterator.next();
+ List extensibilityElements =
port.getExtensibilityElements();
+ for (int i = 0; i < extensibilityElements.size();
i++) {
+ Object extElement =
extensibilityElements.get(i);
+ if (extElement instanceof HTTPAddress) {
+ // HTTP address found - keep this and loop
until http address is found
+ returnPort = port;
+ String location =
+ ((HTTPAddress)
extElement).getLocationURI().trim();
+ if ((location != null) &&
location.startsWith("http:")) {
+ // i.e we have found an http port so
return from here
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (returnPort == null) {
+ throw Context.reportRuntimeError("The WSDL given does not
contain any ports " +
+ "that use the http transport");
+ } else {
+ serviceQName = service.getQName();
+ endpointName = returnPort.getName();
+
}
- }
- if (returnPort == null) {
- throw Context.reportRuntimeError("The WSDL given does not
contain any ports " +
- "that use the http transport");
}
ConfigurationContext defaultConfigurationContext =
ConfigurationContextFactory.createDefaultConfigurationContext();
- wsRequest.sender =
- new ServiceClient(defaultConfigurationContext,
definition, service.getQName(),
- returnPort.getName());
+ wsRequest.sender =
+ new ServiceClient(defaultConfigurationContext,
definition, serviceQName,
+ endpointName);
wsRequest.targetNamespace = definition.getTargetNamespace();
} catch (MalformedURLException e) {
throw new MashupFault(e);
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev