You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/08/07 22:05:20 UTC
cvs commit: xml-axis/java/src/org/apache/axis/server AxisServer.java
gdaniels 01/08/07 13:05:20
Modified: java/docs user-guide.html
java/samples/echo TestClient.java
java/samples/stock GetQuote.java
java/samples/transport/tcp GetQuote.java
java/src/org/apache/axis AxisFault.java
java/src/org/apache/axis/encoding ServiceDescription.java
java/src/org/apache/axis/server AxisServer.java
Log:
Start of improvements to AxisFault, add getBasePath() to AxisServer,
latest doc edits, and change setOutputParam() to setOutputType() in
ServiceDescription.
Revision Changes Path
1.7 +61 -6 xml-axis/java/docs/user-guide.html
Index: user-guide.html
===================================================================
RCS file: /home/cvs/xml-axis/java/docs/user-guide.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- user-guide.html 2001/08/06 19:43:33 1.6
+++ user-guide.html 2001/08/07 20:05:19 1.7
@@ -29,12 +29,16 @@
<A href="#DeploymentReference">Deployment Reference</a><br>
<A href="#Glossary">Glossary</a></p>
<h2><a name="Introduction"></a>Introduction</h2>
-Welcome to Axis! This is the <b>alpha 1</b> version, our first publically annouced
-milestone. Please note that this is a work in progress, and although the basic
-functionality is there, there are still a lot of unfinished areas and rough edges
-- so watch your step, and don't expect perfection. That said, we're very psyched
-about the package so far, and would love to get your take on how we can make it
-better.
+<ul>
+ <li>Bugzilla link</li>
+ <li>ServiceDescription desc.</li>
+</ul>
+<p>Welcome to Axis! This is the <b>alpha 1</b> version, our first publically annouced
+ milestone. Please note that this is a work in progress, and although the basic
+ functionality is there, there are still a lot of unfinished areas and rough
+ edges - so watch your step, and don't expect perfection. That said, we're very
+ psyched about the package so far, and would love to get your take on how we
+ can make it better. </p>
<h3>What is Axis?</h3>
<p>Axis is the third generation of Apache SOAP, which began at IBM as "SOAP4J"
and then became Apache SOAP version 2. The committers on the v2 project began
@@ -196,6 +200,57 @@
</div>
<p>You'll note the param is now named "testParam" as expected.</p>
+<h3>Interoperating with "untyped" servers</h3>
+<p>In the above examples, we've been casting the return type of invoke(), which
+ is Object, to the appropriate "real" type - for instance, we know
+ that the "echoString" method returns a String, so we expect to get
+ one back from client.invoke(). Let's take a moment and investigate how this
+ happens, which sheds light on a potential problem (to which, of course, we have
+ a solution - so don't fret :)).</p>
+<p>Here's what a typical response might look like to the "echoString"
+ method: </p>
+<pre><div class="xml"><?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SOAP-ENV:Body>
+ <ns1:echoStringResponse xmlns:ns1="http://soapinterop.org/">
+ <result <font color="#FF0000">xsi:type="xsd:string"</font>>Hello!</result>
+ </ns1:echoStringResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope></div></pre>
+<p>Take a look at the bit which we've highlighted in red - that attribute is a
+ schema <b>type declaration</b>, which Axis uses to figure out that the contents
+ of that element are, in this case, deserializable into a Java String object.
+ Many toolkits will put this kind of explicit typing information in the XML,
+ to make the message "self-describing". On the other hand, some toolkits
+ will return responses that look like this:</p>
+<pre><div class="xml"><?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SOAP-ENV:Body>
+ <ns1:echoStringResponse xmlns:ns1="http://soapinterop.org/">
+ <result>Hello!</result>
+ </ns1:echoStringResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope></div></pre>
+<p>There's no type in the message - so how do we know what Java object we should
+ deserialize the <result> element into? The answer is <b>metadata</b> -
+ data about data. In this case, we need a <b>description</b> of the service which
+ tells us what to expect as the return type. Here's how to do it on the client
+ side in Axis:</p>
+<div class="example">
+ <pre> ServiceDescription sd = new ServiceDescription("name", true);
+ sd.setOutputType(new QName(Constants.SCHEMA_URI, "string"));
+ client.setServiceDescription(sd);</pre>
+</div>
+<p>The ServiceDescription constructor takes a name (can be anything) and a boolean
+ as arguments; the boolean indicates if the service is RPC or not - in this case
+ it is, so we use "true". Then we call "setOutputType()",
+ which tells the ServiceDescription that if the return element is not typed,
+ act as if the return value has an xsi:type attribute set to the QName which
+ we supply.</p>
<p>OK - so now you know the basics of accessing SOAP services as a client. But
how do you publish your own services?</p>
<h2><a name="PublishingServices"></a>Publishing Web Services with Axis</h2>
1.24 +1 -1 xml-axis/java/samples/echo/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/TestClient.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- TestClient.java 2001/08/02 16:50:02 1.23
+++ TestClient.java 2001/08/07 20:05:19 1.24
@@ -151,7 +151,7 @@
// Default return type based on what we expect
ServiceDescription sd = new ServiceDescription(method, true);
- sd.setOutputParam(map.getTypeQName(toSend.getClass()));
+ sd.setOutputType(map.getTypeQName(toSend.getClass()));
call.setServiceDescription(sd);
}
1.25 +1 -1 xml-axis/java/samples/stock/GetQuote.java
Index: GetQuote.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- GetQuote.java 2001/07/07 14:24:33 1.24
+++ GetQuote.java 2001/08/07 20:05:19 1.25
@@ -96,7 +96,7 @@
ServiceClient call = new ServiceClient(opts.getURL());
ServiceDescription sd = new ServiceDescription("stockQuotes", true);
sd.addInputParam("symbol", SOAPTypeMappingRegistry.XSD_STRING);
- sd.setOutputParam(SOAPTypeMappingRegistry.XSD_FLOAT);
+ sd.setOutputType(SOAPTypeMappingRegistry.XSD_FLOAT);
call.setServiceDescription(sd);
// TESTING HACK BY ROBJ
1.4 +1 -1 xml-axis/java/samples/transport/tcp/GetQuote.java
Index: GetQuote.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/GetQuote.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GetQuote.java 2001/07/07 14:25:08 1.3
+++ GetQuote.java 2001/08/07 20:05:19 1.4
@@ -99,7 +99,7 @@
call.setTransport(new TCPTransport());
ServiceDescription sd = new ServiceDescription("stockQuotes", true);
sd.addInputParam("symbol", SOAPTypeMappingRegistry.XSD_STRING);
- sd.setOutputParam(SOAPTypeMappingRegistry.XSD_FLOAT);
+ sd.setOutputType(SOAPTypeMappingRegistry.XSD_FLOAT);
call.setServiceDescription(sd);
// TESTING HACK BY ROBJ
1.24 +8 -2 xml-axis/java/src/org/apache/axis/AxisFault.java
Index: AxisFault.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- AxisFault.java 2001/07/12 15:02:46 1.23
+++ AxisFault.java 2001/08/07 20:05:19 1.24
@@ -97,13 +97,19 @@
String str ;
setFaultCode( Constants.FAULT_SERVER_GENERAL );
- // setFaultString( e.toString() );
+ setFaultString( e.toString() );
+
// need to set details if we were in the body at the time!!
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintStream ps = new PrintStream( stream );
e.printStackTrace(ps);
ps.close();
- setFaultString( stream.toString() );
+
+ Element elem = XMLUtils.newDocument().createElement("details");
+ elem.setNodeValue(ps.toString());
+
+ Element [] details = new Element [] { elem };
+ setFaultDetails( details );
}
public AxisFault(String message)
1.7 +1 -1 xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java
Index: ServiceDescription.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServiceDescription.java 2001/07/04 14:20:56 1.6
+++ ServiceDescription.java 2001/08/07 20:05:19 1.7
@@ -138,7 +138,7 @@
outputParams.addElement(new Param(name, type));
}
- public void setOutputParam(QName type)
+ public void setOutputType(QName type)
{
outputParams.addElement(new Param(null, type));
}
1.33 +3 -0 xml-axis/java/src/org/apache/axis/server/AxisServer.java
Index: AxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- AxisServer.java 2001/07/30 02:29:28 1.32
+++ AxisServer.java 2001/08/07 20:05:19 1.33
@@ -102,6 +102,9 @@
{
basePath = path;
}
+ public static String getBasePath()
+ { return basePath; };
+
public static synchronized AxisServer getSingleton()
{
if (singleton == null) {