dims 2002/12/28 09:59:06
Modified: java/test/wsdl/interop4/groupG/dime/rpc
AttachmentsBindingImpl.java build.xml
DimeRPCInteropTestCase.java
java/src/org/apache/axis/wsdl/symbolTable BindingEntry.java
SymbolTable.java
java/src/org/apache/axis Constants.java
java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
java/src/org/apache/axis/utils XMLUtils.java
Log:
Initial Impl to enable DIME support in WSDL2Java. Needed for GroupG. Needs more work.
Revision Changes Path
1.2 +7 -8
xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/AttachmentsBindingImpl.java
Index: AttachmentsBindingImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/AttachmentsBindingImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttachmentsBindingImpl.java 26 Dec 2002 23:26:22 -0000 1.1
+++ AttachmentsBindingImpl.java 28 Dec 2002 17:59:06 -0000 1.2
@@ -8,7 +8,7 @@
package test.wsdl.interop4.groupG.dime.rpc;
public class AttachmentsBindingImpl implements
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType{
- public test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary
echoAttachment(test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary in) throws
java.rmi.RemoteException {
+ public org.apache.axis.attachments.OctetStream
echoAttachment(org.apache.axis.attachments.OctetStream in) throws
java.rmi.RemoteException {
return in;
}
@@ -16,19 +16,18 @@
return in;
}
- public byte[]
echoAttachmentAsBase64(test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary in)
throws java.rmi.RemoteException {
- return in.getValue();
+ public byte[] echoAttachmentAsBase64(org.apache.axis.attachments.OctetStream
in) throws java.rmi.RemoteException {
+ return in.getBytes();
}
- public test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary
echoBase64AsAttachment(byte[] in) throws java.rmi.RemoteException {
- return new test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary(in);
+ public org.apache.axis.attachments.OctetStream echoBase64AsAttachment(byte[]
in) throws java.rmi.RemoteException {
+ return new org.apache.axis.attachments.OctetStream(in);
}
public void echoUnrefAttachments() throws java.rmi.RemoteException {
- //TODO: What should we do here?
}
- public java.lang.String
echoAttachmentAsString(test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedText in)
throws java.rmi.RemoteException {
- return new String(in.getValue());
+ public java.lang.String echoAttachmentAsString(java.lang.String in) throws
java.rmi.RemoteException {
+ return in;
}
}
1.4 +2 -0 xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/build.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build.xml 26 Dec 2002 23:26:22 -0000 1.3
+++ build.xml 28 Dec 2002 17:59:06 -0000 1.4
@@ -71,12 +71,14 @@
</wsdl2java>
<mkdir dir="${build.dest}"/>
+ <!--
<copy
file="${axis.home}/test/wsdl/interop4/groupG/dime/rpc/DimeRPCInteropTestCase.java"
todir="${root.dir}/build/work/test/wsdl/interop4/groupG/dime/rpc"
overwrite="yes"/>
<copy
file="${axis.home}/test/wsdl/interop4/groupG/dime/rpc/AttachmentsBindingImpl.java"
todir="${root.dir}/build/work/test/wsdl/interop4/groupG/dime/rpc"
overwrite="yes"/>
+ -->
<!-- compile the skeletons -->
<javac srcdir="${build.dir}/work"
destdir="${build.dest}" debug="on">
1.2 +37 -25
xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/DimeRPCInteropTestCase.java
Index: DimeRPCInteropTestCase.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/test/wsdl/interop4/groupG/dime/rpc/DimeRPCInteropTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DimeRPCInteropTestCase.java 26 Dec 2002 23:26:22 -0000 1.1
+++ DimeRPCInteropTestCase.java 28 Dec 2002 17:59:06 -0000 1.2
@@ -7,16 +7,22 @@
package test.wsdl.interop4.groupG.dime.rpc;
-import java.util.Arrays;
+import java.net.URL;
public class DimeRPCInteropTestCase extends junit.framework.TestCase {
public DimeRPCInteropTestCase(java.lang.String name) {
super(name);
}
+
+ protected void setUp() throws Exception {
+ if(url == null) {
+ url = new URL(new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress());
+ }
+ }
public void test1DimeRPCSoapPortEchoAttachment() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -25,18 +31,17 @@
}
assertTrue("binding is null", binding != null);
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary input = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachment".getBytes());
// Test operation
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary output = null;
+ org.apache.axis.attachments.OctetStream input = new
org.apache.axis.attachments.OctetStream("EchoAttachment".getBytes());
+ org.apache.axis.attachments.OctetStream output = null;
output = binding.echoAttachment(input);
// TBD - validate results
- assertTrue(Arrays.equals(input.getValue(),output.getValue()));
}
public void test2DimeRPCSoapPortEchoAttachments() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -45,22 +50,19 @@
}
assertTrue("binding is null", binding != null);
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary input[] = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary[2];
- input[0] = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachments0".getBytes());
- input[1] = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachments1".getBytes());
-
// Test operation
+ test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary[] input = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary[2];
+ input[0] = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachments0".getBytes());
+ input[1] = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachments1".getBytes());
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary[] output = null;
output = binding.echoAttachments(input);
// TBD - validate results
- assertTrue(Arrays.equals(input[0].getValue(),output[0].getValue()));
- assertTrue(Arrays.equals(input[1].getValue(),output[1].getValue()));
}
public void test3DimeRPCSoapPortEchoAttachmentAsBase64() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -69,18 +71,17 @@
}
assertTrue("binding is null", binding != null);
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary input = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary("EchoAttachmentAsBase64".getBytes());
+ org.apache.axis.attachments.OctetStream input = new
org.apache.axis.attachments.OctetStream("EchoAttachmentAsBase64".getBytes());
// Test operation
- byte[] output = null;
- output = binding.echoAttachmentAsBase64(input);
+ byte[] value = null;
+ value = binding.echoAttachmentAsBase64(input);
// TBD - validate results
- assertTrue(Arrays.equals(input.getValue(),output));
}
public void test4DimeRPCSoapPortEchoBase64AsAttachment() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -89,18 +90,17 @@
}
assertTrue("binding is null", binding != null);
- byte input[] = "EchoBase64AsAttachment".getBytes();
+ byte[] input = "EchoBase64AsAttachment".getBytes();
// Test operation
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedBinary output = null;
+ org.apache.axis.attachments.OctetStream output = null;
output = binding.echoBase64AsAttachment(input);
// TBD - validate results
- assertTrue(Arrays.equals(input,output.getValue()));
}
public void test5DimeRPCSoapPortEchoUnrefAttachments() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -109,7 +109,6 @@
}
assertTrue("binding is null", binding != null);
- // TODO: What do we do here?
// Test operation
binding.echoUnrefAttachments();
// TBD - validate results
@@ -118,7 +117,7 @@
public void test6DimeRPCSoapPortEchoAttachmentAsString() throws Exception {
test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding;
try {
- binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort();
+ binding = new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url);
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
@@ -127,9 +126,22 @@
}
assertTrue("binding is null", binding != null);
- test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedText input = new
test.wsdl.interop4.groupG.dime.rpc.xsd.ReferencedText("3344");
+ java.lang.String input = "EchoAttachmentAsString";
+
// Test operation
java.lang.String output = null;
output = binding.echoAttachmentAsString(input);
+ // TBD - validate results
}
+
+ public static URL url = null;
+
+ public static void main(String[] args) throws Exception {
+ if (args.length == 1) {
+ url = new URL(args[0]);
+ } else {
+ url = new URL(new
test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress());
+ }
+ junit.textui.TestRunner.run(new
junit.framework.TestSuite(DimeRPCInteropTestCase.class));
+ } // main
}
1.8 +23 -0
xml-axis/java/src/org/apache/axis/wsdl/symbolTable/BindingEntry.java
Index: BindingEntry.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/BindingEntry.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BindingEntry.java 11 Dec 2002 22:38:29 -0000 1.7
+++ BindingEntry.java 28 Dec 2002 17:59:06 -0000 1.8
@@ -63,6 +63,7 @@
import javax.wsdl.extensions.soap.SOAPFault;
import java.util.HashMap;
import java.util.Map;
+import java.util.ArrayList;
/**
* This class represents a WSDL binding. It encompasses the WSDL4J Binding object
so it can
@@ -101,6 +102,9 @@
// Booleans.
private Map headerParts;
+ // List of operations at need to use DIME
+ private ArrayList dimeOps = new ArrayList();
+
/**
* Construct a BindingEntry from a WSDL4J Binding object and the additional
binding info:
* binding type, binding style, whether there is any literal binding, and the
attributes which
@@ -216,6 +220,25 @@
opMap.put(parameterName, type);
} // setMIMEType
+ /**
+ * Mark the operation as a DIME operation
+ * @param operationName
+ */
+ public void setOperationDIME(String operationName) {
+ if(dimeOps.indexOf(operationName)==-1){
+ dimeOps.add(operationName);
+ }
+ }
+
+ /**
+ * Check if this operation should use DIME
+ * @param operationName
+ * @return
+ */
+ public boolean isOperationDIME(String operationName){
+ return (dimeOps.indexOf(operationName)>=0);
+ }
+
/**
* Is this part an input header part?.
*/
1.63 +52 -0
xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
Index: SymbolTable.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- SymbolTable.java 26 Dec 2002 21:37:00 -0000 1.62
+++ SymbolTable.java 28 Dec 2002 17:59:06 -0000 1.63
@@ -93,6 +93,7 @@
import javax.wsdl.extensions.soap.SOAPFault;
import javax.wsdl.extensions.soap.SOAPHeader;
import javax.wsdl.extensions.soap.SOAPHeaderFault;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
@@ -1675,9 +1676,60 @@
bEntry.setBodyType(operation,
addMIMETypes(bEntry, (MIMEMultipartRelated) obj,
operation), input);
+ } else if (obj instanceof UnknownExtensibilityElement) {
+ UnknownExtensibilityElement unkElement =
(UnknownExtensibilityElement) obj;
+ QName name = unkElement.getElementType();
+ if(name.getNamespaceURI().equals(Constants.URI_DIME_WSDL) &&
+ name.getLocalPart().equals("message")) {
+ fillInDIMEInformation(unkElement, input, operation, bEntry);
+ }
}
}
} // fillInBindingInfo
+
+ /**
+ * Fill in DIME information
+ *
+ * @param unkElement
+ * @param input
+ * @param operation
+ * @param bEntry
+ */
+ private void fillInDIMEInformation(UnknownExtensibilityElement unkElement,
boolean input, Operation operation, BindingEntry bEntry) {
+ String layout = unkElement.getElement().getAttribute("layout");
+ // TODO: what to do with layout info?
+ if(layout.equals(Constants.URI_DIME_CLOSED_LAYOUT)) {
+ } else if(layout.equals(Constants.URI_DIME_OPEN_LAYOUT)){
+ }
+ Map parts = null;
+ if(input){
+ parts = operation.getInput().getMessage().getParts();
+ } else {
+ parts = operation.getOutput().getMessage().getParts();
+ }
+ if(parts != null) {
+ Iterator iterator = parts.values().iterator();
+ while(iterator.hasNext()){
+ Part part = (Part) iterator.next();
+ if(part != null){
+ org.w3c.dom.Element element = null;
+ if(part.getTypeName() != null) {
+ Type partType = getType(part.getTypeName());
+ element = (org.w3c.dom.Element) partType.getNode();
+ } else if(part.getElementName() != null) {
+ Element partElement = getElement(part.getElementName());
+ element = (org.w3c.dom.Element) partElement.getNode();
+ }
+ org.w3c.dom.Element e =
(org.w3c.dom.Element)XMLUtils.findNode(element, new QName(Constants.URI_DIME_CONTENT,
"mediaType"));
+ if(e != null){
+ String value = e.getAttribute("value");
+ bEntry.setOperationDIME(operation.getName());
+ bEntry.setMIMEType(operation.getName(), part.getName(),
value);
+ }
+ }
+ }
+ }
+ }
/**
* Get the faults from the soap:fault clause.
1.102 +19 -0 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- Constants.java 20 Dec 2002 17:28:21 -0000 1.101
+++ Constants.java 28 Dec 2002 17:59:06 -0000 1.102
@@ -377,6 +377,25 @@
}
//
+ // WSDL extensions for SOAP in DIME
+ // (http://gotdotnet.com/team/xml_wsspecs/dime/WSDL-Extension-for-DIME.htm)
+ //
+ public static final String URI_DIME_WSDL =
+ "http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/";
+
+ public static final String URI_DIME_CONTENT =
+
"http://schemas.xmlsoap.org/ws/2002/04/content-type/";
+
+ public static final String URI_DIME_REFERENCE=
+ "http://schemas.xmlsoap.org/ws/2002/04/reference/";
+
+ public static final String URI_DIME_CLOSED_LAYOUT=
+
"http://schemas.xmlsoap.org/ws/2002/04/dime/closed-layout";
+
+ public static final String URI_DIME_OPEN_LAYOUT=
+
"http://schemas.xmlsoap.org/ws/2002/04/dime/open-layout";
+
+ //
// WSDL SOAP Namespace
//
public static final String URI_WSDL11_SOAP =
1.107 +5 -0
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
Index: JavaStubWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- JavaStubWriter.java 11 Dec 2002 22:38:30 -0000 1.106
+++ JavaStubWriter.java 28 Dec 2002 17:59:06 -0000 1.107
@@ -732,6 +732,11 @@
// Set the headers
pw.println(" setRequestHeaders(_call);");
+
+ // Set DIME flag if needed
+ if(bEntry.isOperationDIME(operation.getOperation().getName())) {
+ pw.println("
_call.setProperty(_call.ATTACHMENT_ENCAPSULATION_FORMAT,
_call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);");
+ }
// Invoke the operation
if (oneway) {
1.76 +21 -0 xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
Index: XMLUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- XMLUtils.java 19 Dec 2002 15:12:25 -0000 1.75
+++ XMLUtils.java 28 Dec 2002 17:59:06 -0000 1.76
@@ -66,6 +66,7 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
+import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -726,5 +727,25 @@
public static InputSource getEmptyInputSource() {
return new InputSource(bais);
+ }
+
+ /**
+ * Find a Node with a given QName
+ *
+ * @param node parent node
+ * @param name QName of the child we need to find
+ * @return child node
+ */
+ public static Node findNode(Node node, QName name){
+ if(name.getNamespaceURI().equals(node.getNamespaceURI()) &&
+ name.getLocalPart().equals(node.getLocalName()))
+ return node;
+ NodeList children = node.getChildNodes();
+ for(int i=0;i<children.getLength();i++){
+ Node ret = findNode(children.item(i), name);
+ if(ret != null)
+ return ret;
+ }
+ return null;
}
}