snichol 2002/11/18 18:47:39
Modified: java/docs changes.html
java/src/org/apache/soap/messaging Message.java
java/src/org/apache/soap/rpc Call.java SOAPContext.java
java/src/org/apache/soap/transport TransportMessage.java
java/src/org/apache/soap/util/net HTTPUtils.java
Log:
Added client support for one-way calls as defined by WSDL. The client
receives a null Envelope for the messaging API or a null Response for the
RPC API. The RPC API was tested against a .NET server.
Based in part on a submission by Pavel Ausianik <[EMAIL PROTECTED]>.
Revision Changes Path
1.51 +1 -0 xml-soap/java/docs/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/xml-soap/java/docs/changes.html,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- changes.html 18 Oct 2002 13:36:00 -0000 1.50
+++ changes.html 19 Nov 2002 02:47:38 -0000 1.51
@@ -95,6 +95,7 @@
rather than throwing a NPE.</li>
<li>Add client support for HTTP redirects.</li>
<li>Allow additional transport headers to be specified by client.</li>
+ <li>Add client support for one-way (as defined in WSDL) calls.</li>
</ul>
</li>
</ul>
1.12 +3 -1 xml-soap/java/src/org/apache/soap/messaging/Message.java
Index: Message.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/messaging/Message.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Message.java 18 Oct 2002 13:36:00 -0000 1.11
+++ Message.java 19 Nov 2002 02:47:38 -0000 1.12
@@ -148,7 +148,7 @@
* If the (root part of) the response does not have text/xml as the
* Content-Type, null will be returned. If the response is not a
* SOAP envelope, receive() should be used instead.
- * @return the envelope received
+ * @return the envelope received or null if a one-way response was received.
* @exception SOAPException if something goes wrong
* @see #receive()
*/
@@ -160,6 +160,8 @@
}
try {
resCtx = st.getResponseSOAPContext ();
+ if (resCtx.getOneWay())
+ return null;
String payloadStr = Call.getEnvelopeString (st);
Document doc =
1.22 +5 -0 xml-soap/java/src/org/apache/soap/rpc/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/Call.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Call.java 14 Nov 2002 16:22:08 -0000 1.21
+++ Call.java 19 Nov 2002 02:47:38 -0000 1.22
@@ -312,6 +312,7 @@
* @param url the URL to send the envelope to
* @param SOAPActionURI the SOAPAction header field value
* @param headers any other header fields to go to as protocol headers
+ * @return The response or null for a one-way response.
*/
public Response invoke(URL url, String SOAPActionURI, Hashtable headers) throws
SOAPException
{
@@ -344,6 +345,10 @@
// Get the response context.
SOAPContext respCtx = st.getResponseSOAPContext();
+
+ // Check for a one-way reponse.
+ if (respCtx.getOneWay())
+ return null;
// Pre-read the response root part as a String to be able to
// log it in an exception if parsing fails.
1.15 +15 -0 xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java
Index: SOAPContext.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SOAPContext.java 14 Nov 2002 16:22:08 -0000 1.14
+++ SOAPContext.java 19 Nov 2002 02:47:38 -0000 1.15
@@ -89,6 +89,7 @@
protected boolean docLitSerialization = false;
protected Boolean gzip = null;
protected Boolean acceptGzip = null;
+ protected boolean oneWay = false;
// Constants for checking type for base64 encoding
private static MimeType MIME_STREAM;
@@ -748,6 +749,20 @@
*/
public Object getDeserializedMultiRef(String id) {
return deserializedMultiRef.get(id);
+ }
+
+ /**
+ * Gets whether this is a one-way response.
+ */
+ public boolean getOneWay() {
+ return oneWay;
+ }
+
+ /**
+ * Sets whether this is a one-way response.
+ */
+ public void setOneWay(boolean oneWay) {
+ this.oneWay = oneWay;
}
/**
1.21 +4 -1
xml-soap/java/src/org/apache/soap/transport/TransportMessage.java
Index: TransportMessage.java
===================================================================
RCS file:
/home/cvs/xml-soap/java/src/org/apache/soap/transport/TransportMessage.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TransportMessage.java 14 Nov 2002 16:22:09 -0000 1.20
+++ TransportMessage.java 19 Nov 2002 02:47:38 -0000 1.21
@@ -265,9 +265,12 @@
contentType.substring(pos+1) ;
cType = MimeUtils.getContentType(contentType);
}
- if (cType == null)
+ if (cType == null) {
+ if (ctx.getOneWay())
+ return null;
throw new SOAPException(Constants.FAULT_CODE_PROTOCOL,
"Missing content type.");
+ }
// Check encoding
String encoding = (String) HTTPUtils.getHeaderValue(headers,
1.38 +6 -0 xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java
Index: HTTPUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- HTTPUtils.java 18 Nov 2002 17:55:54 -0000 1.37
+++ HTTPUtils.java 19 Nov 2002 02:47:38 -0000 1.38
@@ -607,6 +607,7 @@
"Error parsing HTTP header line \"" + new String(linebuf, 0, count,
ISO_8859_1) + "\": " + e, e);
}
+ boolean isOneWay = false;
/* Handle redirect here */
if (statusCode >= HttpURLConnection.HTTP_MULT_CHOICE &&
statusCode <= HttpURLConnection.HTTP_USE_PROXY &&
@@ -622,6 +623,9 @@
return post(newURL, request, timeout, httpProxyHost, httpProxyPort,
outputBufferSize, tcpNoDelay, null, responseCopy, numRedirects);
}
+ } else if (statusCode == HttpURLConnection.HTTP_ACCEPTED) {
+ // One-way message response
+ isOneWay = true;
}
// TODO: process differently depending on statusCode and respContentLength
@@ -635,6 +639,8 @@
try {
// Create response SOAPContext.
ctx = new SOAPContext();
+ ctx.setOneWay(isOneWay);
+
// Read content.
response = new TransportMessage(bInStream, respContentLength,
respContentType, ctx, respHeaders);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>