Author: chinthaka
Date: Wed Jun 14 04:13:51 2006
New Revision: 414195
URL: http://svn.apache.org/viewvc?rev=414195&view=rev
Log:
We do not want to mess with built-in schemas. Ignoring them whenever possible.
Writing wsdl is getting fine, but need to improve the contents as some
operations seems missing.
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WSDL2.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java?rev=414195&r1=414194&r2=414195&view=diff
==============================================================================
---
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
(original)
+++
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
Wed Jun 14 04:13:51 2006
@@ -1,10 +1,16 @@
package org.apache.axis2.description;
-import org.apache.axiom.om.*;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.namespace.Constants;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
@@ -23,7 +29,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.StringWriter;
-import java.net.URL;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
@@ -82,7 +87,7 @@
private HashMap policiesInDefinitions;
public AxisService2OM(AxisService service, String[] serviceURL,
- String style, String use, String servicePath) {
+ String style, String use, String servicePath) {
this.axisService = service;
urls = serviceURL;
if (style == null) {
@@ -105,7 +110,7 @@
DEFAULT_WSDL_NAMESPACE_PREFIX);
OMElement ele = fac.createOMElement("definitions", wsdl);
setDefinitionElement(ele);
-
+
policiesInDefinitions = new HashMap();
Map nameSpaceMap = axisService.getNameSpacesMap();
@@ -144,14 +149,18 @@
// XmlSchema schema = (XmlSchema) schemas.get(i);
XmlSchema schema = axisService.getSchema(i);
- schema.write(writer);
- if (!"".equals(writer.toString())) {
- XMLStreamReader xmlReader = StAXUtils
- .createXMLStreamReader(new ByteArrayInputStream(writer
- .toString().getBytes()));
- StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac,
xmlReader);
- wsdlTypes.addChild(staxOMBuilder.getDocumentElement());
+ String targetNamespace = schema.getTargetNamespace();
+ if (!Constants.NS_URI_XML.equals(targetNamespace)) {
+ schema.write(writer);
+ String schemaString = writer.toString();
+ if (!"".equals(schemaString)) {
+ XMLStreamReader xmlReader = StAXUtils
+ .createXMLStreamReader(new
ByteArrayInputStream(schemaString.getBytes()));
+
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac,
xmlReader);
+ wsdlTypes.addChild(staxOMBuilder.getDocumentElement());
+ }
}
}
@@ -232,7 +241,7 @@
}
private void generateHeaderMessages(AxisMessage axismessage, OMFactory fac,
- OMElement defintions) {
+ OMElement defintions) {
ArrayList extList = axismessage.getSoapHeaders();
for (int i = 0; i < extList.size(); i++) {
SOAPHeaderMessage header = (SOAPHeaderMessage) extList.get(i);
@@ -252,7 +261,7 @@
}
private void writeMessage(AxisMessage axismessage, OMFactory fac,
- OMElement defintions) {
+ OMElement defintions) {
QName schemaElementName = axismessage.getElementQName();
OMElement messageElement = fac
.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
@@ -383,7 +392,7 @@
for (int i = 0; i < urls.length; i++) {
String urlString = urls[i];
String protocol = urlString == null ? null : new
URI(urlString).getScheme();
- if(urlString == null) {
+ if (urlString == null) {
urlString = "REPLACE_WITH_ACTUAL_URL";
}
OMElement port = fac.createOMElement(PORT, wsdl);
@@ -425,7 +434,7 @@
for (int i = 0; i < urls.length; i++) {
String urlString = urls[i];
String protocol = urlString == null ? null : new
URI(urlString).getScheme();
- if(urlString == null) {
+ if (urlString == null) {
urlString = "REPLACE_WITH_ACTUAL_URL";
}
OMElement port = fac.createOMElement(PORT, wsdl);
@@ -769,7 +778,7 @@
}
private void writeSoapHeaders(AxisMessage inaxisMessage, OMFactory fac,
- OMElement input, OMNamespace soapNameSpace) throws Exception {
+ OMElement input, OMNamespace soapNameSpace)
throws Exception {
ArrayList extElementList;
extElementList = inaxisMessage.getSoapHeaders();
if (extElementList != null) {
@@ -783,8 +792,8 @@
}
private void addExtensionElemnet(OMFactory fac, OMElement element,
- String name, String att1Name, String att1Value, String att2Name,
- String att2Value, OMNamespace soapNameSpace) {
+ String name, String att1Name, String
att1Value, String att2Name,
+ String att2Value, OMNamespace
soapNameSpace) {
OMElement soapbinding = fac.createOMElement(name, soapNameSpace);
element.addChild(soapbinding);
soapbinding.addAttribute(att1Name, att1Value, null);
@@ -794,8 +803,8 @@
}
private void addExtensionElement(OMFactory fac, OMElement element,
- String name, String att1Name, String att1Value,
- OMNamespace soapNameSpace) {
+ String name, String att1Name, String
att1Value,
+ OMNamespace soapNameSpace) {
OMElement extElement = fac.createOMElement(name, soapNameSpace);
element.addChild(extElement);
extElement.addAttribute(att1Name, att1Value, null);
@@ -810,7 +819,7 @@
}
private void addSOAPHeader(OMFactory fac, OMElement element,
- SOAPHeaderMessage header, OMNamespace soapNameSpace) {
+ SOAPHeaderMessage header, OMNamespace
soapNameSpace) {
OMElement extElement = fac.createOMElement("header", soapNameSpace);
element.addChild(extElement);
String use = header.getUse();
@@ -839,7 +848,7 @@
}
private void addPolicyAsExtElement(int type, PolicyInclude policyInclude,
- OMElement element, OMFactory factory) throws Exception {
+ OMElement element, OMFactory factory)
throws Exception {
ArrayList elementList = policyInclude.getPolicyElements(type);
StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
@@ -887,7 +896,7 @@
throw new Exception("Policy not found for uri : "
+ policyURIString);
}
-
+
addPolicyToDefinitionElement(key, p);
}
@@ -896,7 +905,7 @@
}
private void addPolicyAsExtAttribute(int type, PolicyInclude policyInclude,
- OMElement element, OMFactory factory) throws Exception {
+ OMElement element, OMFactory factory)
throws Exception {
ArrayList elementList = policyInclude.getPolicyElements(type);
StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
@@ -915,31 +924,31 @@
Policy p = (Policy) policyElement;
if (p.getId() != null) {
- id = "#" + p.getId();
+ id = "#" + p.getId();
} else if (p.getName() != null) {
id = p.getName();
} else {
throw new RuntimeException(
"Can't add the Policy as an extensibility
attribute since it doesn't have a id or a name attribute");
}
-
+
policyURIs.add(id);
addPolicyToDefinitionElement(id, p);
-
+
} else {
String policyURIString = ((PolicyReference) policyElement)
.getPolicyURIString();
PolicyRegistry registry = policyInclude.getPolicyRegistry();
-
+
String key;
if (policyURIString.startsWith("#")) {
key =
policyURIString.substring(policyURIString.indexOf('#') + 1);
} else {
key = policyURIString;
}
-
+
Policy p = registry.lookup(key);
-
+
if (p == null) {
throw new RuntimeException("Cannot resolve " +
policyURIString + " to a Policy");
}
@@ -959,7 +968,7 @@
PolicyConstants.POLICY_NAMESPACE_URI,
PolicyConstants.POLICY_PREFIX);
OMAttribute URIs = factory.createOMAttribute("PolicyURIs", ns,
- value);
+ value);
element.addAttribute(URIs);
}
@@ -967,14 +976,14 @@
}
private void addPoliciesToDefinitionElement(Iterator iterator,
- OMElement definitionElement, OMFactory factory) throws Exception {
+ OMElement definitionElement,
OMFactory factory) throws Exception {
Policy policy;
ByteArrayInputStream bais;
ByteArrayOutputStream baos;
OMElement policyElement;
OMNode firstChild;
- for (;iterator.hasNext();) {
+ for (; iterator.hasNext();) {
policy = (Policy) iterator.next();
baos = new ByteArrayOutputStream();
getPolicyWriter().writePolicy(policy, baos);
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WSDL2.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WSDL2.java?rev=414195&r1=414194&r2=414195&view=diff
==============================================================================
---
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WSDL2.java
(original)
+++
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WSDL2.java
Wed Jun 14 04:13:51 2006
@@ -6,6 +6,7 @@
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.namespace.Constants;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
@@ -89,14 +90,19 @@
for (int i = 0; i < schemas.size(); i++) {
StringWriter writer = new StringWriter();
XmlSchema schema = axisService.getSchema(i);
- schema.write(writer);
- if (!"".equals(writer.toString())) {
- XMLStreamReader xmlReader = StAXUtils
- .createXMLStreamReader(new ByteArrayInputStream(writer
- .toString().getBytes()));
- StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac,
xmlReader);
- wsdlTypes.addChild(staxOMBuilder.getDocumentElement());
+ if
(!Constants.URI_2001_SCHEMA_XSD.equals(schema.getTargetNamespace())) {
+ schema.write(writer);
+ String schemaString = writer.toString();
+
+ if (!"".equals(schemaString)) {
+ System.out.println("schemaString = " + schemaString);
+ XMLStreamReader xmlReader = StAXUtils
+ .createXMLStreamReader(new
ByteArrayInputStream(schemaString.getBytes()));
+
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac,
xmlReader);
+ wsdlTypes.addChild(staxOMBuilder.getDocumentElement());
+ }
}
}
//generating interface
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?rev=414195&r1=414194&r2=414195&view=diff
==============================================================================
---
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
(original)
+++
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
Wed Jun 14 04:13:51 2006
@@ -1,6 +1,7 @@
package org.apache.axis2.description;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.namespace.Constants;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.woden.WSDLException;
import org.apache.woden.WSDLFactory;
@@ -24,6 +25,7 @@
import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.policy.Policy;
import org.apache.ws.policy.PolicyReference;
import org.apache.ws.policy.util.DOMPolicyReader;
@@ -72,7 +74,7 @@
private Map namespacemap;
public WSDL20ToAxisServiceBuilder(InputStream in, QName serviceName,
- String interfaceName) {
+ String interfaceName) {
this.in = in;
this.serviceName = serviceName;
this.interfaceName = interfaceName;
@@ -81,7 +83,7 @@
}
public WSDL20ToAxisServiceBuilder(DescriptionElement descriptionElement,
- QName serviceName, String interfaceName) {
+ QName serviceName, String interfaceName)
{
savedTargetNamespace = descriptionElement.getTargetNamespace()
.toString();
namespacemap = descriptionElement.getNamespaces();
@@ -127,6 +129,14 @@
// setting target name space
axisService.setTargetNamespace(savedTargetNamespace);
+ // if there are documentation elements in the root. Lets add them
as the service description
+ // but since there can be multiple documentation elements, lets
only add the first one
+// DocumentationElement[] documentationElements =
description.toElement().getDocumentationElements();
+// if (documentationElements != null &&
documentationElements.length > 0) {
+//
axisService.setServiceDescription(documentationElements[0].getContent().toString());
+// }
+
+
// adding ns in the original WSDL
// processPoliciesInDefintion(wsdl4jDefinition); TODO : Defering
policy handling for now - Chinthaka
// policy support
@@ -161,7 +171,14 @@
if (typesElement != null) {
Schema[] schemas = typesElement.getSchemas();
for (int i = 0; i < schemas.length; i++) {
- axisService.addSchema(schemas[i].getSchemaDefinition());
+ XmlSchema schemaDefinition =
schemas[i].getSchemaDefinition();
+
+
+ // WSDL 2.0 spec requires that even the built-in schema
should be returned
+ // once asked for schema definitions. But for data binding
purposes we can ignore that
+ if (schemaDefinition != null &&
!Constants.URI_2001_SCHEMA_XSD.equals(schemaDefinition.getTargetNamespace())) {
+ axisService.addSchema(schemaDefinition);
+ }
}
}
@@ -197,7 +214,7 @@
Interface serviceInterface = binding.getInterface();
processInterface(serviceInterface, description);
-
+
// BindingOperation[] bindingOperations =
binding.getBindingOperations();
// for(int i=0; i<bindingOperations.length; i++){
// BindingOperation bindingOperation = bindingOperations[i];
@@ -279,7 +296,7 @@
}
private AxisOperation populateOperations(InterfaceOperation operation,
- Description description) throws Exception {
+ Description description) throws
Exception {
QName opName = operation.getName();
// Copy Name Attribute
AxisOperation axisOperation = axisService.getOperation(opName);
@@ -299,7 +316,7 @@
// assuming the style of the operations of WSDL 2.0 is always document.
axisOperation.setStyle("document");
-
+
// copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(),
// dif,
// axisOperation, PORT_TYPE_OPERATION);
@@ -333,22 +350,22 @@
}
}
if (messageReference.getMessageLabel().equals(
- messageReference.getMessageLabel().OUT)){
- if(isServerSide){
+ messageReference.getMessageLabel().OUT)) {
+ if (isServerSide) {
AxisMessage outMessage = axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
outMessage.setElementQName(messageReference
- .getElementDeclaration().getName());
+ .getElementDeclaration().getName());
outMessage.setName(messageReference
.getElementDeclaration().getName().getLocalPart());
// TODO copy policy elements
- }else{
+ } else {
AxisMessage outMessage = axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
outMessage.setElementQName(messageReference
- .getElementDeclaration().getName());
+ .getElementDeclaration().getName());
outMessage.setName(messageReference
.getElementDeclaration().getName().getLocalPart());
// TODO copy policy elements
@@ -357,21 +374,21 @@
}
InterfaceFaultReference[] faults =
operation.getInterfaceFaultReferences();
- for(int i=0; i<faults.length; i++){
+ for (int i = 0; i < faults.length; i++) {
AxisMessage faultMessage = new AxisMessage();
faultMessage.setElementQName(faults[i].toElement().getInterfaceFaultElement().getElementName());
faultMessage.setName(faults[i].toElement().getRef().getLocalPart());
axisOperation.setFaultMessages(faultMessage);
}
-
-
+
+
return axisOperation;
}
private void copyExtensibleElements(ExtensionElement[] extensionElement,
- DescriptionElement descriptionElement, AxisDescription description,
- String originOfExtensibilityElements) {
+ DescriptionElement descriptionElement,
AxisDescription description,
+ String originOfExtensibilityElements) {
for (int i = 0; i < extensionElement.length; i++) {
ExtensionElement element = extensionElement[i];
@@ -572,7 +589,7 @@
}
private Element createSchemaForInterface(InterfaceElement interfaceElement,
- String targetNamespaceUri, boolean forceWrapping) {
+ String targetNamespaceUri,
boolean forceWrapping) {
// loop through the messages. We'll populate things map with the
// relevant
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]