antelder 2003/01/21 09:34:09 Modified: java/src/org/apache/wsif/base WSIFClientProxy.java java/src/org/apache/wsif/providers/soap/apacheaxis WSIFOperation_ApacheAxis.java java/src/org/apache/wsif WSIFConstants.java java/test/interop InteropDocTest.java Log: Bugzilla 15780 - part 2 of this fix enabling the forcing of the use of 'wrapped' to allow stubs to work properly with wrapped doc/lit. Revision Changes Path 1.16 +27 -1 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java Index: WSIFClientProxy.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- WSIFClientProxy.java 3 Jan 2003 14:39:15 -0000 1.15 +++ WSIFClientProxy.java 21 Jan 2003 17:34:08 -0000 1.16 @@ -76,6 +76,7 @@ import javax.wsdl.PortType; import javax.xml.namespace.QName; +import org.apache.wsif.WSIFConstants; import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; @@ -293,7 +294,13 @@ Iterator partIt = inputParts.iterator(); for (int argIndex = 0; partIt.hasNext(); argIndex++) { Part part = (Part) partIt.next(); - String partName = part.getName(); + String partName; + if (isWrappedInContext()) { + QName qn = part.getElementName(); + partName = (qn == null) ? "" : qn.getLocalPart(); + } else { + partName = part.getName(); + } wsifInputMessage.setObjectPart(partName, args[argIndex]); } } @@ -646,6 +653,25 @@ parts.remove(p); parts.addAll(unWrappedParts); } + } + + private boolean isWrappedInContext() throws WSIFException { + WSIFMessage context = wsifport.getContext(); + String style = null; + try { + style = + (String) context.getObjectPart( + WSIFConstants.CONTEXT_OPERATION_STYLE); + } catch (WSIFException e) { + Trc.ignoredException(e); + } + boolean wrappedInContext; + if (WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED.equals(style)) { + wrappedInContext = true; + } else { + wrappedInContext = false; + } + return wrappedInContext; } public String deep() { 1.68 +17 -2 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.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- WSIFOperation_ApacheAxis.java 21 Jan 2003 12:05:05 -0000 1.67 +++ WSIFOperation_ApacheAxis.java 21 Jan 2003 17:34:09 -0000 1.68 @@ -1450,8 +1450,22 @@ * the unwrapped SOAP parts, otherwise false */ private boolean isInputMessageUnWrapped(WSIFMessage msg) { - boolean unWrapped = (inputUnwrappedSOAPParts != null); - if (unWrapped) { + boolean unWrapped = true; + + Object style = null; + try { + WSIFMessage context = getContext(); + style = context.getObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE); + } catch (WSIFException e) { + Trc.ignoredException(e); + } + if (WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED.equals(style)) { + unWrapped = true; + } else if (WSIFConstants.CONTEXT_OPERATION_STYLE_UNWRAPPED.equals(style)) { + unWrapped = false; + } else if (inputUnwrappedSOAPParts != null + && inputUnwrappedSOAPParts.size() > 0) { + unWrapped = true; for (Iterator i=inputUnwrappedSOAPParts.iterator(); i.hasNext() && unWrapped; ) { Part p = (Part) i.next(); try { @@ -1461,6 +1475,7 @@ } } } + return unWrapped; } 1.17 +18 -0 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- WSIFConstants.java 20 Jan 2003 13:53:55 -0000 1.16 +++ WSIFConstants.java 21 Jan 2003 17:34:09 -0000 1.17 @@ -149,6 +149,24 @@ public static final String CONTEXT_JMS_PREFIX = "JMSProperty."; /** + * WSIF context part name for the AXIS operation style + */ + public static final String CONTEXT_OPERATION_STYLE = + "org.apache.wsif.axis.operationStyle"; + + /** + * WSIF context value for AXIS wrapped operation style + */ + public static final String CONTEXT_OPERATION_STYLE_WRAPPED = + "wrapped"; + + /** + * WSIF context value for AXIS unwrapped operation style + */ + public static final String CONTEXT_OPERATION_STYLE_UNWRAPPED = + "unwrapped"; + + /** * SOAP faults WSIFMessage part name for the fault code */ public static final String SOAP_FAULT_MSG_NAME = 1.4 +185 -12 xml-axis-wsif/java/test/interop/InteropDocTest.java Index: InteropDocTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/interop/InteropDocTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InteropDocTest.java 3 Jan 2003 14:55:36 -0000 1.3 +++ InteropDocTest.java 21 Jan 2003 17:34:09 -0000 1.4 @@ -57,29 +57,24 @@ package interop; -import interop.wsifserviceWrapped.ArrayOfSimpleDocument; -import interop.wsifserviceWrapped.ChildDocument; -import interop.wsifserviceWrapped.ComplexDocument_Type; -import interop.wsifserviceWrapped.Doc_TestPortType; -import interop.wsifserviceWrapped.SimpleDocument_Type; -import interop.wsifserviceWrapped.SingleTagResponse; -import interop.wsifserviceWrapped.SingleTag_ElemType; -import interop.wsifserviceWrapped.SingleTag_Type; -import java.io.StringWriter; +import interop.wsifservice.ArrayOfSimpleDocument; +import interop.wsifservice.ChildDocument; +import interop.wsifservice.ComplexDocument_Type; +import interop.wsifservice.Doc_TestPortType; +import interop.wsifservice.SimpleDocument_Type; +import interop.wsifservice.SingleTag_Type; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.apache.wsif.WSIFConstants; import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFService; import org.apache.wsif.WSIFServiceFactory; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; -import org.w3c.dom.Element; import util.TestUtilities; /** @@ -132,6 +127,15 @@ public void testComplexDocumentDII() { doitComplexDocumentDII("interopDocPort", "axis"); } + public void testSingleTagStub() { + doitSingleTagStub("interopDocPort", "axis"); + } + public void testSimpleDocumentStub() { + doitSimpleDocumentStub("interopDocPort", "axis"); + } + public void testComplexDocumentStub() { + doitComplexDocumentStub("interopDocPort", "axis"); + } private void doitSingleTagDII(String portName, String protocol) { if (portName.toUpperCase().indexOf("JMS") != -1 @@ -337,6 +341,175 @@ "response part has wrong type: " + o.getClass(), ComplexDocument_Type.class.isAssignableFrom(o.getClass())); checkComplexDocument((ComplexDocument_Type)o); + + } catch (Exception ex) { + ex.printStackTrace(); + assertTrue( + "InteropDocTest.doitComplexDocumentDII(" + + portName + + ") caught exception " + + ex.getLocalizedMessage(), + false); + } + } + + private void doitSingleTagStub(String portName, String protocol) { + if (portName.toUpperCase().indexOf("JMS") != -1 + && !TestUtilities.areWeTesting("jms")) + return; + + TestUtilities.setProviderForProtocol(protocol); + + try { + WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); + WSIFService service = + factory.getService( + wsdlLocation, + null, + null, + "http://soapinterop.org/", + "Doc_TestPortType"); + + service.mapPackage("http://soapinterop.org/", "interop.wsifservice"); + + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "SingleTag"), + SingleTag_Type.class ); + + // force to use a 'wrapped' type operation + WSIFMessage context = service.getContext(); + context.setObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE, WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED); + service.setContext(context); + + Doc_TestPortType stub = (Doc_TestPortType) service.getStub(portName, Doc_TestPortType.class); + + SingleTag_Type stet = new SingleTag_Type(); + + SingleTag_Type response = stub.singleTag(stet); + + assertNotNull("response is null!!!", response); + + } catch (Exception ex) { + ex.printStackTrace(); + assertTrue( + "InteropDocTest.doitSingleTagDII(" + + portName + + ") caught exception " + + ex.getLocalizedMessage(), + false); + } + } + + private void doitSimpleDocumentStub(String portName, String protocol) { + if (portName.toUpperCase().indexOf("JMS") != -1 + && !TestUtilities.areWeTesting("jms")) + return; + + TestUtilities.setProviderForProtocol(protocol); + + try { + WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); + WSIFService service = + factory.getService( + wsdlLocation, + null, + null, + "http://soapinterop.org/", + "Doc_TestPortType"); + + service.mapPackage("http://soapinterop.org/", "interop.wsifservice"); + + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "SimpleDocument"), + SimpleDocument_Type.class ); + + // force to use a 'wrapped' type operation + WSIFMessage context = service.getContext(); + context.setObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE, WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED); + service.setContext(context); + + Doc_TestPortType stub = (Doc_TestPortType) service.getStub(portName, Doc_TestPortType.class); + + SimpleDocument_Type sdt = new SimpleDocument_Type(); + sdt.setValue("petra"); + + SimpleDocument_Type response = stub.simpleDocument(sdt); + + assertNotNull("response is null!!!", response); + + assertTrue( + "simpleDocument value wrong: " + response.getValue(), + sdt.getValue().equals(response.getValue())); + + } catch (Exception ex) { + ex.printStackTrace(); + assertTrue( + "InteropDocTest.doitSimpleDocumentDII(" + + portName + + ") caught exception " + + ex.getLocalizedMessage(), + false); + } + } + + private void doitComplexDocumentStub(String portName, String protocol) { + if (portName.toUpperCase().indexOf("JMS") != -1 + && !TestUtilities.areWeTesting("jms")) + return; + + TestUtilities.setProviderForProtocol(protocol); + + try { + WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); + WSIFService service = + factory.getService( + wsdlLocation, + null, + null, + "http://soapinterop.org/", + "Doc_TestPortType"); + + service.mapPackage("http://soapinterop.org/", "interop.wsifservice"); + + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "ComplexDocument"), + ComplexDocument_Type.class ); + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "ArrayOfSimpleDocument"), + ArrayOfSimpleDocument.class ); + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "SimpleDocument"), + SimpleDocument_Type.class ); + service.mapType( + new javax.xml.namespace.QName( + "http://soapinterop.org/", + "ChildDocument"), + ChildDocument.class ); + + // force to use a 'wrapped' type operation + WSIFMessage context = service.getContext(); + context.setObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE, WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED); + service.setContext(context); + + Doc_TestPortType stub = (Doc_TestPortType) service.getStub(portName, Doc_TestPortType.class); + + ComplexDocument_Type cdt = makeComplexDocument(); + checkComplexDocument(cdt); + + ComplexDocument_Type response = stub.complexDocument(cdt); + assertNotNull("response is null!!!", response); + + checkComplexDocument(response); } catch (Exception ex) { ex.printStackTrace();