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 wh...@apache.org on 2005/06/14 18:27:59 UTC
cvs commit: ws-axis/c/tests/utils/monitor/org/apache/test MockServerThread.java
whitlock 2005/06/14 09:27:59
Modified: c/src/soap SoapSerializer.cpp
c/tests/auto_build/testcases/dynamic/DynUnrefAttachmentTest
DynUnrefAttachmentTest.cpp
c/tests/utils/monitor/org/apache/test MockServerThread.java
Log:
Client-side unreferenced attachments.
Add more function to the DynUnrefAttachmentTest
Fix the SoapSerializer to cope with client-side attachments, where there are no response mime headers yet
Fix the mock server so that it can cope with mime messages. It now looks for either a soap envelope end tag or a mime boundary to check that it's received the whole of the message, This is not perfect since it should really use the content length, but it is probably good enough for the current unit tests.
Revision Changes Path
1.121 +25 -18 ws-axis/c/src/soap/SoapSerializer.cpp
Index: SoapSerializer.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- SoapSerializer.cpp 10 Jun 2005 03:09:34 -0000 1.120
+++ SoapSerializer.cpp 14 Jun 2005 16:27:59 -0000 1.121
@@ -301,27 +301,34 @@
{
if( checkAttachmentAvailability())
{
- string asStartID;
- string asSOAPMimeHeaders;
+ char *pszSOAPMimeHeaders = pStream->getIncomingSOAPMimeHeaders();
+ if (NULL != pszSOAPMimeHeaders)
+ { // Server code
+ string asSOAPMimeHeaders = pszSOAPMimeHeaders;
+ int start = asSOAPMimeHeaders.find( "Content-Type");
+ int startPosIdValue = asSOAPMimeHeaders.find( "<", start + strlen( "Content-Id:")) + 1;
+ int endPosIdValue = asSOAPMimeHeaders.find( ">", start + strlen( "Content-Type"));
+ int length = endPosIdValue - startPosIdValue ;
+
+ string asStartID = asSOAPMimeHeaders.substr (startPosIdValue,length);
+
+ string * asContentType = new string( "multipart/related; type=\"text/xml\"; start=\"<");
- asSOAPMimeHeaders = pStream->getIncomingSOAPMimeHeaders();
+ *asContentType = *asContentType + asStartID + ">\"";
+ *asContentType = *asContentType + "; boundary=\"------=MIME BOUNDARY\"";
- int start = asSOAPMimeHeaders.find( "Content-Type");
- int startPosIdValue = asSOAPMimeHeaders.find( "<", start + strlen( "Content-Id:")) + 1;
- int endPosIdValue = asSOAPMimeHeaders.find( ">", start + strlen( "Content-Type"));
- int length = endPosIdValue - startPosIdValue ;
+ pStream->setTransportProperty( CONTENT_TYPE, (*asContentType).c_str());
- asStartID = asSOAPMimeHeaders.substr (startPosIdValue,length);
-
- string * asContentType = new string( "multipart/related; type=\"text/xml\"; start=\"<");
-
- *asContentType = *asContentType + asStartID + ">\"";
- *asContentType = *asContentType + "; boundary=\"------=MIME BOUNDARY\"";
-
- pStream->setTransportProperty( CONTENT_TYPE, (*asContentType).c_str());
-
- serialize( "\n------=MIME BOUNDARY\n", NULL);
- serialize( pStream->getIncomingSOAPMimeHeaders(), "\n\n", NULL);
+ serialize( "\n------=MIME BOUNDARY\n", NULL);
+ serialize( pStream->getIncomingSOAPMimeHeaders(), "\n\n", NULL);
+ }
+ else
+ { // Client code
+ #define MIME_BOUNDARY "----=MIME_BOUNDARY"
+ pStream->setTransportProperty( CONTENT_TYPE,
+ "multipart/related; type=\"text/xml\"; boundary=\"" MIME_BOUNDARY "\"");
+ serialize("\n" MIME_BOUNDARY "\n", NULL);
+ }
}
serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
1.2 +14 -0 ws-axis/c/tests/auto_build/testcases/dynamic/DynUnrefAttachmentTest/DynUnrefAttachmentTest.cpp
Index: DynUnrefAttachmentTest.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/dynamic/DynUnrefAttachmentTest/DynUnrefAttachmentTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DynUnrefAttachmentTest.cpp 14 Jun 2005 09:34:44 -0000 1.1
+++ DynUnrefAttachmentTest.cpp 14 Jun 2005 16:27:59 -0000 1.2
@@ -15,6 +15,7 @@
#include <axis/AxisException.hpp>
#include <axis/client/Call.hpp>
#include <axis/AxisWrapperAPI.hpp>
+#include <axis/ISoapAttachment.hpp>
#include <iostream>
#include <string>
#include <exception>
@@ -27,6 +28,19 @@
{
Call call;
call.setEndpointURI(argv[1]);
+
+ ISoapAttachment *att = call.createSoapAttachment();
+ att->addHeader("Content-Id","HERES_MY_CONTENT_ID");
+ att->addHeader("Content-Type","text/plain");
+
+ xsd__base64Binary b64b;
+ char *text = "This is the attachment body for the DynUnrefAttachmentTest";
+ b64b.__ptr = (xsd__unsignedByte*)text;
+ b64b.__size = strlen(text)+1;
+ att->addBody(&b64b);
+
+ call.addAttachment(att);
+
call.initialize(CPP_DOC_PROVIDER);
call.setSOAPVersion(SOAP_VER_1_1);
call.setTransportProperty(SOAPACTION_HEADER , "Trash");
1.3 +6 -5 ws-axis/c/tests/utils/monitor/org/apache/test/MockServerThread.java
Index: MockServerThread.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/utils/monitor/org/apache/test/MockServerThread.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MockServerThread.java 10 Jun 2005 15:33:39 -0000 1.2
+++ MockServerThread.java 14 Jun 2005 16:27:59 -0000 1.3
@@ -33,6 +33,7 @@
{
// NOTE: We read in this string plus two bytes (the end of the request)
private static String ENVELOPE_TAG ="</SOAP-ENV:Envelope>";
+ private static String MIME_BOUNDARY ="MIME BOUNDARY";
private static int CHARBUFFER_SIZE =20000;
@@ -163,12 +164,12 @@
if (bytesRead>ENVELOPE_TAG.length( )+2)
{
String envelopeString=new String(charBuffer, bytesRead
- -(ENVELOPE_TAG.length( )+2), ENVELOPE_TAG.length( ));
- // System.out
- // .println("MockServerThread#run():EnvelopeString = "
- // +envelopeString);
+ -(ENVELOPE_TAG.length( )+2), ENVELOPE_TAG.length( )+2);
+ System.out
+ .println("MockServerThread#run():EnvelopeString = "
+ +envelopeString);
// Check whether this is an envelope or not
- if (envelopeString.startsWith(ENVELOPE_TAG))
+ if (envelopeString.startsWith(ENVELOPE_TAG) || envelopeString.indexOf(MIME_BOUNDARY)!=-1)
{
System.out
.println("MockServerThread#run():Got an envelope");