Improved the Web service classes, needs to be tested

RESOLVED - #92 
http://bugs.koc.se/view.php?id=92
This commit is contained in:
Ziver Koc 2011-09-14 20:30:06 +00:00
parent 09b671bda7
commit a2b6be1f35
13 changed files with 401 additions and 817 deletions

View file

@ -21,16 +21,16 @@
******************************************************************************/
package zutil.test;
import javax.wsdl.WSDLException;
import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import zutil.net.http.soap.SOAPHttpPage;
import zutil.net.ws.WSInterface;
import zutil.net.ws.WSObject;
import zutil.net.ws.WSReturnValueList;
import zutil.net.ws.WSInterface.*;
import zutil.net.ws.WSReturnObject;
import zutil.net.ws.WebServiceDef;
import zutil.parser.wsdl.WSDLWriter;
public class SOAPTest {
@ -42,64 +42,65 @@ public class SOAPTest {
}
public SOAPTest(){
try {
SOAPHttpPage soap = new SOAPHttpPage("http://test.se:8080/", new SOAPTestClass());
// Response
try {
Document document = soap.genSOAPResponse(
"<?xml version=\"1.0\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body xmlns:m=\"http://www.example.org/stock\">\n" +
//" <m:pubA>\n" +
//" <m:Ztring>IBM</m:Ztring>\n" +
//" </m:pubA>\n" +
//" <m:pubZ>\n" +
//" <m:olle>66</m:olle>\n" +
//" </m:pubZ>\n" +
" <m:pubB>\n" +
" <m:byte>IBM</m:byte>\n" +
" </m:pubB>\n" +
" </soap:Body>\n" +
"</soap:Envelope>");
System.out.println( "****************** RESPONSE *********************" );
WebServiceDef wsDef = new WebServiceDef( SOAPTestClass.class );
SOAPHttpPage soap = new SOAPHttpPage( wsDef );
WSDLWriter wsdl = new WSDLWriter( wsDef );
wsdl.write(System.out);
// Response
try {
Document document = soap.genSOAPResponse(
"<?xml version=\"1.0\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body xmlns:m=\"http://www.example.org/stock\">\n" +
//" <m:pubA>\n" +
//" <m:Ztring>IBM</m:Ztring>\n" +
//" </m:pubA>\n" +
//" <m:pubZ>\n" +
//" <m:olle>66</m:olle>\n" +
//" </m:pubZ>\n" +
" <m:pubB>\n" +
" <m:byte>IBM</m:byte>\n" +
" </m:pubB>\n" +
" </soap:Body>\n" +
"</soap:Envelope>");
System.out.println( "****************** RESPONSE *********************" );
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter( System.out, format );
writer.write( document );
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter( System.out, format );
writer.write( document );
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
} catch (WSDLException e) {
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
}
public class SOAPTestClass3 implements WSObject{
public static class SOAPTestClass3 extends WSReturnObject{
public String lol = "lol11";
public String lol2 = "lol22";
}
public class SOAPTestClass2 implements WSObject{
@WSFieldName(value="lolz", optional=true)
public static class SOAPTestClass2 extends WSReturnObject{
@WSValueName(value="lolz")
public String lol = "lol1";
@WSFieldName("lolx")
@WSValueName("lolx")
public String lol2 = "lol2";
public byte[] b = new byte[]{0x12, 0x23};
public SOAPTestClass3 l = new SOAPTestClass3();
}
public class SOAPTestRetClass extends WSReturnValueList{
public static class SOAPTestRetClass extends WSReturnObject{
@WSValueName("retTest")
public String lol = "lol1";
public String lol2 = "lol2";
}
public class SOAPTestClass implements WSInterface{
@WSNamespace("http://test.se:8080/")
public static class SOAPTestClass implements WSInterface{
public SOAPTestClass(){}
@WSHeader()
@WSDocumentation("hello")
public void pubZ(

View file

@ -32,6 +32,7 @@ import zutil.net.http.soap.SOAPHttpPage;
import zutil.net.ssdp.SSDPServer;
import zutil.net.upnp.UPnPMediaServer;
import zutil.net.upnp.services.UPnPContentDirectory;
import zutil.net.ws.WebServiceDef;
public class UPnPServerTest {
@ -40,13 +41,15 @@ public class UPnPServerTest {
MultiPrintStream.out.println("UPNP Server running");
UPnPContentDirectory cds = new UPnPContentDirectory(new File("C:\\Users\\Ziver\\Desktop\\lan"));
WebServiceDef ws = new WebServiceDef( UPnPContentDirectory.class );
HttpServer http = new HttpServer("http://192.168.0.60/", 8080);
//http.setDefaultPage(upnp);
http.setPage("/RootDesc", upnp );
http.setPage("/SCP/ContentDir", cds );
SOAPHttpPage soap = new SOAPHttpPage("Action/ContentDir", cds);
soap.enableSession(false);
SOAPHttpPage soap = new SOAPHttpPage(ws);
soap.setObject( cds );
soap.enableSession( false );
http.setPage("/Action/ContentDir", soap );
http.start();
MultiPrintStream.out.println("HTTP Server running");