antelder 2003/01/21 03:52:24
Modified: java/src/org/apache/wsif Tag: pre1_2_0-patches
WSIFConstants.java
java/src/org/apache/wsif/providers/soap/apacheaxis Tag:
pre1_2_0-patches WSIFOperation_ApacheAxis.java
java/src/org/apache/wsif/providers/soap/apachesoap Tag:
pre1_2_0-patches WSIFOperation_ApacheSOAP.java
Added: java/test/soap Tag: pre1_2_0-patches FakeSQRespHeaderOK.txt
HeadersTest.java
Log:
Bug 16199 - enable passing back any SOAP headers to the client by adding them to the
Context message
Revision Changes Path
No revision
No revision
1.1.2.1 +13 -0 xml-axis-wsif/java/test/soap/Attic/FakeSQRespHeaderOK.txt
1.1.2.1 +328 -0 xml-axis-wsif/java/test/soap/Attic/HeadersTest.java
No revision
No revision
1.12.2.1 +14 -1 xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java
Index: WSIFConstants.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- WSIFConstants.java 15 Oct 2002 15:33:12 -0000 1.12
+++ WSIFConstants.java 21 Jan 2003 11:52:23 -0000 1.12.2.1
@@ -125,10 +125,23 @@
"org.apache.wsif.http.Password";
/**
- * WSIF context part name for SOAP headers
+ * WSIF context part name for SOAP headers
+ * @deprecated use CONTEXT_REQUEST_SOAP_HEADERS
*/
public static final String CONTEXT_SOAP_HEADERS =
"org.apache.wsif.soap.RequestHeaders";
+
+ /**
+ * WSIF context part name for SOAP headers
+ */
+ public static final String CONTEXT_REQUEST_SOAP_HEADERS =
+ "org.apache.wsif.soap.RequestHeaders";
+
+ /**
+ * WSIF context part name for SOAP headers
+ */
+ public static final String CONTEXT_RESPONSE_SOAP_HEADERS =
+ "org.apache.wsif.soap.ResponseHeaders";
/**
* WSIF context part name prefix for JMSProperties
No revision
No revision
1.28.2.2 +65 -1
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
Index: WSIFOperation_ApacheAxis.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -u -r1.28.2.1 -r1.28.2.2
--- WSIFOperation_ApacheAxis.java 4 Nov 2002 16:50:45 -0000 1.28.2.1
+++ WSIFOperation_ApacheAxis.java 21 Jan 2003 11:52:23 -0000 1.28.2.2
@@ -72,6 +72,7 @@
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
@@ -598,6 +599,7 @@
Trc.entry(this, wsifmessage, wsifmessage1, wsifmessage2);
Call call = portInstance.getCall();
+ call.clearHeaders();
Transport axistransport = getTransport();
WSIFJMSDestination dest = null;
@@ -702,6 +704,8 @@
buildResponseMessages(response, wsifmessage1,
wsifmessage2);
}
+ setResponseContext(call);
+
Trc.exit(respOK);
return respOK;
}
@@ -1056,6 +1060,7 @@
private void setCallContext(Call call) {
Object o;
String name;
+
if (context == null) {
return;
}
@@ -1080,7 +1085,7 @@
}
try {
- name = WSIFConstants.CONTEXT_SOAP_HEADERS;
+ name = WSIFConstants.CONTEXT_REQUEST_SOAP_HEADERS;
o = context.getObjectPart(name);
if (o instanceof List) {
addSOAPHeader(call, name, (List) o);
@@ -1090,6 +1095,32 @@
}
}
+ /**
+ * This sets up any context from the response message
+ */
+ private void setResponseContext(Call call) throws WSIFException {
+ org.apache.axis.Message m = call.getResponseMessage();
+ if (m != null) {
+ javax.xml.soap.SOAPEnvelope env;
+ try {
+ env = m.getSOAPEnvelope();
+ } catch (AxisFault e) {
+ throw new WSIFException(
+ "AxisFault getting response SOAP envelope", e);
+ }
+ if (env != null) {
+ javax.xml.soap.SOAPHeader soapHeader;
+ try {
+ soapHeader = env.getHeader();
+ } catch (SOAPException e) {
+ throw new WSIFException(
+ "SOAPException getting response headers from SOAP
envelope", e);
+ }
+ addContextResponseSOAPHeaders(soapHeader);
+ }
+ }
+ }
+
/**
* Sets the SOAP headers in the message context.
*/
@@ -1116,6 +1147,39 @@
call.setProperty(Call.PASSWORD_PROPERTY, value);
}
}
+
+ /**
+ * This adds any SOAP headers in the response to the context
+ */
+ private void addContextResponseSOAPHeaders(
+ javax.xml.soap.SOAPHeader soapHeader) throws WSIFException {
+
+ if( soapHeader != null ) {
+ ArrayList headers = new ArrayList();
+ for(Iterator i = soapHeader.getChildElements(); i.hasNext(); ) {
+ Object o = i.next();
+ if (o instanceof SOAPHeaderElement) {
+ SOAPHeaderElement she = (SOAPHeaderElement) o;
+ try {
+ headers.add(she.getAsDOM());
+ } catch (Exception e) {
+ throw new WSIFException(
+ "exception getting response SOAP header",
+ e);
+ }
+ } else {
+ Trc.event("unexpected response SOAP header type: ", o);
+ }
+ }
+ if (headers.size() > 0) {
+ WSIFMessage context = getContext();
+ context.setObjectPart(
+ WSIFConstants.CONTEXT_RESPONSE_SOAP_HEADERS,
+ headers);
+ setContext(context);
+ }
+ }
+ }
private void checkForTimeoutProperties(
HashMap inJmsPropVals,
No revision
No revision
1.30.2.5 +39 -1
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java
Index: WSIFOperation_ApacheSOAP.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java,v
retrieving revision 1.30.2.4
retrieving revision 1.30.2.5
diff -u -r1.30.2.4 -r1.30.2.5
--- WSIFOperation_ApacheSOAP.java 18 Dec 2002 10:47:47 -0000 1.30.2.4
+++ WSIFOperation_ApacheSOAP.java 21 Jan 2003 11:52:24 -0000 1.30.2.5
@@ -706,6 +706,11 @@
respOK = buildResponseMessages(resp, output, fault);
}
+ if (resp instanceof Response) {
+ Header soapHeader = resp.getHeader();
+ addContextResponseSOAPHeaders(soapHeader);
+ }
+
Trc.exit(respOK);
return respOK;
}
@@ -889,6 +894,10 @@
Object retBean = bean.value;
}
}
+
+ Header soapHeader = env.getHeader();
+ addContextResponseSOAPHeaders(soapHeader);
+
Trc.exit(true);
return true;
}
@@ -1539,7 +1548,7 @@
}
try {
- name = WSIFConstants.CONTEXT_SOAP_HEADERS;
+ name = WSIFConstants.CONTEXT_REQUEST_SOAP_HEADERS;
o = context.getObjectPart(name);
if (o instanceof List) {
addSOAPHeader(call, name, (List) o);
@@ -1572,6 +1581,35 @@
} else if (name.equals(WSIFConstants.CONTEXT_HTTP_PSWD)) {
httpTransport.setPassword(value);
}
+ }
+ }
+
+ /**
+ * This adds any SOAP headers in the response to the context
+ */
+ private void addContextResponseSOAPHeaders(Header soapHeader)
+ throws WSIFException {
+
+ if( soapHeader != null ) {
+ Vector headerEntries = soapHeader.getHeaderEntries();
+ if (headerEntries != null) {
+ ArrayList headers = new ArrayList();
+ for(Iterator i = headerEntries.iterator(); i.hasNext(); ) {
+ Object o = i.next();
+ if (o instanceof Element) {
+ headers.add(o);
+ } else {
+ Trc.event("unexpected response SOAP header type: ", o);
+ }
+ }
+ if (headers.size() > 0) {
+ WSIFMessage context = getContext();
+ context.setObjectPart(
+ WSIFConstants.CONTEXT_RESPONSE_SOAP_HEADERS,
+ headers);
+ setContext(context);
+ }
+ }
}
}