cTmp = getClass(fields[i].getType());
+ if(SOAPObject.class.isAssignableFrom(cTmp)){
+ element.addAttribute("type", "tns:"+cTmp.getSimpleName().toLowerCase());
+ if(!types.contains(cTmp))
+ types.add(cTmp);
+ }
+ else
+ element.addAttribute("type", "xsd:"+cTmp.getSimpleName().toLowerCase());
+ // Is the Field optional
+ if(tmp != null && tmp.optional())
+ element.addAttribute("minOccurs", "0");
+ }
+ }
+ }
+
+ private Class> getClass(Class> c){
+ if(c.isArray()){
+ return getClass(c.getComponentType());
+ }
+ return c;
+ }
+
+ //*******************************************************************************************
+ //**************************** TEST *********************************************************
+
+ public static void main(String[] args){
+ try {
+ new SOAPHttpPage("http://test.se:8080/", new Test()).test();
+ } catch (WSDLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static class TestObject2 implements SOAPObject{
+ public String lol = "lol11";
+ public String lol2 = "lol22";
+ }
+
+ private static class TestObject implements SOAPObject{
+ @SOAPFieldName(value="lolz", optional=true)
+ public String lol = "lol1";
+ @SOAPFieldName("lolx")
+ public String lol2 = "lol2";
+ public TestObject2 l = new TestObject2();
+ }
+
+ private static class Test implements SOAPInterface{
+ public Test(){}
+
+ @SOAPHeader()
+ @WSDLDocumentation("hello")
+ public void pubZ(
+ @SOAPParamName(value="olle", optional=true) int lol) throws Exception{
+ //System.out.println("Param: "+lol);
+ throw new Exception("Ziver is the fizle");
+ }
+
+ @SOAPReturnName("param")
+ @WSDLParamDocumentation("null is the shizzle")
+ public String[][] pubA (
+ @SOAPParamName("Ztring") String lol) throws Exception{
+ //System.out.println("ParamZ: "+lol);
+ return new String[][]{{"test","test2"},{"test3","test4"}};
+ }
+
+ @SOAPReturnName("zivarray")
+ @WSDLParamDocumentation("null is the shizzle")
+ public TestObject[] pubX (
+ @SOAPParamName("Ztring") String lol) throws Exception{
+ return new TestObject[]{new TestObject(), new TestObject()};
+ }
+
+ @SOAPDisabled()
+ public void privaZ(){ }
+ protected void protZ(){ }
+ }
+
+ public void test(){
+ // Response
+ try {
+ Document document = soap(
+ "" +
+ "\n" +
+ " \n" +
+ //" \n" +
+ //" IBM\n" +
+ //" \n" +
+ //" \n" +
+ //" 66\n" +
+ //" \n" +
+ " \n" +
+ " IBM\n" +
+ " \n" +
+ " \n" +
+ "");
+ System.out.println();
+
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ XMLWriter writer = new XMLWriter( System.out, format );
+ writer.write( document );
+
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/zutil/network/http/soap/SOAPInterface.java b/src/zutil/network/http/soap/SOAPInterface.java
new file mode 100644
index 0000000..65f3b9f
--- /dev/null
+++ b/src/zutil/network/http/soap/SOAPInterface.java
@@ -0,0 +1,102 @@
+package zutil.network.http.soap;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * Specifies SOAP parameters names an other things.
+ * Example:
+ *
+ * private static class Test implements SOAPInterface{
+ * public Test(){}
+ *
+ * @SOAPHeader()
+ * @WSDLDocumentation("blabla")
+ * @WSDLParamDocumentation("olle = an variable?")
+ * public void pubZ(
+ * @SOAPParamName("olle") int lol)
+ * throws Exception{
+ * ....
+ * }
+ *
+ * @SOAPReturnName("param")
+ * public String pubA(
+ * @SOAPParamName(value="lol", optional=true) String lol)
+ * throws Exception{
+ * ....
+ * }
+ *
+ * @SOAPDisabled()
+ * public void privaZ(....){
+ * ...
+ * }
+ * }
+ *
+ *
+ * @author Ziver
+ */
+public interface SOAPInterface {
+ /**
+ * Annotation that assigns a name to an parameters
+ * in an method.
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.PARAMETER)
+ public @interface SOAPParamName {
+ String value();
+ boolean optional() default false;
+ }
+
+ /**
+ * Annotation that assigns a name to the return value
+ * in an method.
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface SOAPReturnName {
+ String value();
+ }
+
+ /**
+ * Disables SOAP publication of the given method
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface SOAPDisabled { }
+
+ /**
+ * Method comments for the WSDL.
+ * These comments are put in the operation part of the WSDL
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface WSDLDocumentation{
+ String value();
+ }
+ /**
+ * Parameter comments for the WSDL.
+ * These comments are put in the message part of the WSDL
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface WSDLParamDocumentation{
+ String value();
+ }
+
+ /**
+ * This method will be used in the header of the soap.
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface SOAPHeader { }
+}
diff --git a/src/zutil/network/http/soap/SOAPObject.java b/src/zutil/network/http/soap/SOAPObject.java
new file mode 100644
index 0000000..e2ef5a1
--- /dev/null
+++ b/src/zutil/network/http/soap/SOAPObject.java
@@ -0,0 +1,43 @@
+package zutil.network.http.soap;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This class is used as an return Object for SOAP.
+ * If an class implements this interface then it can return
+ * multiple values through the SOAPInterface. Example:
+ *
+ * private static class TestObject implements SOAPObject{
+ * @SOAPFieldName("name")
+ * public String name;
+ * @SOAPFieldName("lastname")
+ * public String lastname;
+ *
+ * public TestObject(String n, String l){
+ * name = n;
+ * lastname = l;
+ * }
+ * }
+ *
+ *
+ * @author Ziver
+ *
+ */
+public interface SOAPObject{
+ /**
+ * Specifies the SOAP name of an field.
+ * The fields that are available for SOAP should
+ * be declared public.
+ *
+ * @author Ziver
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface SOAPFieldName {
+ String value();
+ boolean optional() default false;
+ }
+}
\ No newline at end of file