dims 2003/01/21 09:01:14 Modified: java/src/org/apache/axis/server AxisServer.java java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java java/test/wsdl/soap12/assertion soap12-test.wsdl java/src/org/apache/axis/message SOAPEnvelope.java java/test/soap12 TestRPC.java java/src/org/apache/axis/enum Use.java Log: Okay....We finally have our first SOAP 1.2 server impl and test case automatically genereate by Wsdl2Java. Revision Changes Path 1.87 +8 -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.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- AxisServer.java 11 Dec 2002 22:38:22 -0000 1.86 +++ AxisServer.java 21 Jan 2003 17:01:12 -0000 1.87 @@ -64,6 +64,7 @@ import org.apache.axis.Message; import org.apache.axis.MessageContext; import org.apache.axis.SimpleTargetedChain; +import org.apache.axis.soap.SOAPConstants; import org.apache.axis.client.AxisClient; import org.apache.axis.components.logger.LogFactory; import org.apache.axis.configuration.EngineConfigurationFactoryFinder; @@ -300,6 +301,7 @@ // chain instead.... Message rm = msgContext.getRequestMessage(); rm.getSOAPEnvelope().getFirstBody(); + h = msgContext.getService(); if (h == null) throw new AxisFault("Server.NoService", @@ -311,6 +313,12 @@ t3=System.currentTimeMillis(); } + // Ensure that if we get SOAP1.2, then reply using SOAP1.2 + if(msgContext.getRequestMessage().getSOAPEnvelope().getSOAPConstants() != null) { + SOAPConstants soapConstants = msgContext.getRequestMessage().getSOAPEnvelope().getSOAPConstants(); + msgContext.setSOAPConstants(soapConstants); + } + h.invoke(msgContext); if( tlog.isDebugEnabled() ) { 1.73 +30 -10 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java Index: JavaDeployWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- JavaDeployWriter.java 1 Jan 2003 22:21:43 -0000 1.72 +++ JavaDeployWriter.java 21 Jan 2003 17:01:12 -0000 1.73 @@ -77,6 +77,8 @@ import javax.wsdl.OperationType; import javax.wsdl.Port; import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.UnknownExtensibilityElement; import javax.xml.namespace.QName; import java.io.IOException; import java.io.PrintWriter; @@ -191,7 +193,8 @@ protected void writeDeployTypes(PrintWriter pw, Binding binding, boolean hasLiteral, - boolean hasMIME) throws IOException { + boolean hasMIME, + Use use) throws IOException { Vector types = symbolTable.getTypes(); pw.println(); @@ -202,7 +205,7 @@ "javax.activation.DataHandler", "org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory", "org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory", - Constants.URI_DEFAULT_SOAP_ENC); + use.getEncoding()); } for (int i = 0; i < types.size(); ++i) { @@ -234,7 +237,7 @@ String deserializerFactory; String encodingStyle = ""; if (!hasLiteral) { - encodingStyle = Constants.URI_DEFAULT_SOAP_ENC; + encodingStyle = use.getEncoding(); } if (javaType.endsWith("[]")) { @@ -291,21 +294,38 @@ String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA; String styleStr = ""; - String useStr = ""; + Use use = Use.DEFAULT; + + Iterator iterator = bEntry.getBinding().getExtensibilityElements().iterator(); + while (iterator.hasNext()) { + Object obj = iterator.next(); + if (obj instanceof SOAPBinding) { + use = Use.ENCODED; + } else if (obj instanceof UnknownExtensibilityElement) { + //TODO: After WSDL4J supports soap12, change this code + UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; + QName name = unkElement.getElementType(); + if(name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && + name.getLocalPart().equals("binding")){ + use = Use.ENCODED12; + } + } + } + if (symbolTable.isWrapped()) { styleStr = " style=\"" + Style.WRAPPED + "\""; - useStr = " use=\"" + Use.LITERAL + "\""; + use = Use.LITERAL; } else { styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\""; if (hasLiteral) { - useStr = " use=\"" + Use.LITERAL + "\""; - } else { - useStr = " use=\"" + Use.ENCODED + "\""; - } + use = Use.LITERAL; + } } + String useStr = " use=\"" + use + "\""; + pw.println(" <service name=\"" + serviceName + "\" provider=\"" + prefix +":RPC" + "\"" + styleStr + useStr + ">"); @@ -323,7 +343,7 @@ } writeDeployBinding(pw, bEntry); - writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME); + writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use); pw.println(" </service>"); } //writeDeployPort 1.2 +8 -1 xml-axis/java/test/wsdl/soap12/assertion/soap12-test.wsdl Index: soap12-test.wsdl =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/soap12/assertion/soap12-test.wsdl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- soap12-test.wsdl 19 Jan 2003 21:25:09 -0000 1.1 +++ soap12-test.wsdl 21 Jan 2003 17:01:13 -0000 1.2 @@ -682,13 +682,20 @@ <service name="WhiteMesaSoap12TestSvc"> - + <!-- <port name="Soap12TestDocPort" binding="tns:Soap12TestDocBinding"> <soap12:address location="http://www.whitemesa.net/soap12/test-doc"/> </port> <port name="Soap12TestRpcPort" binding="tns:Soap12TestRpcBinding"> <soap12:address location="http://www.whitemesa.net/soap12/test-rpc"/> </port> + --> + <port name="Soap12TestDocPort" binding="tns:Soap12TestDocBinding"> + <soap12:address location="http://localhost:8080/axis/services/Soap12TestDocPort"/> + </port> + <port name="Soap12TestRpcPort" binding="tns:Soap12TestRpcBinding"> + <soap12:address location="http://localhost:8080/axis/services/Soap12TestRpcPort"/> + </port> </service> 1.85 +1 -1 xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java Index: SOAPEnvelope.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v retrieving revision 1.84 retrieving revision 1.85 diff -u -r1.84 -r1.85 --- SOAPEnvelope.java 6 Jan 2003 18:30:07 -0000 1.84 +++ SOAPEnvelope.java 21 Jan 2003 17:01:13 -0000 1.85 @@ -427,7 +427,7 @@ context.setPretty(oldPretty); } - SOAPConstants getSOAPConstants() { + public SOAPConstants getSOAPConstants() { return soapConstants; } 1.3 +4 -1 xml-axis/java/test/soap12/TestRPC.java Index: TestRPC.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/soap12/TestRPC.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestRPC.java 19 Jan 2003 21:25:10 -0000 1.2 +++ TestRPC.java 21 Jan 2003 17:01:14 -0000 1.3 @@ -4,6 +4,7 @@ import org.apache.axis.AxisFault; import org.apache.axis.Message; import org.apache.axis.MessageContext; +import org.apache.axis.enum.Use; import org.apache.axis.configuration.SimpleProvider; import org.apache.axis.description.ServiceDesc; import org.apache.axis.handlers.soap.SOAPService; @@ -44,6 +45,7 @@ SOAPService service = new SOAPService(new RPCProvider()); service.setOption("className", "test.soap12.Echo"); service.setOption("allowedMethods", "*"); + service.setOption("use", Use.ENCODED12); ServiceDesc desc = service.getInitializedServiceDesc(null); desc.setDefaultNamespace(method); @@ -52,12 +54,13 @@ MessageContext msgContext = new MessageContext(server); msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS); + msgContext.setEncodingStyle(SOAPConstants.SOAP12_CONSTANTS.getEncodingURI()); String methodNS = null; msgContext.setTargetService(SERVICE_NAME); // Construct the soap request - SOAPEnvelope envelope = new SOAPEnvelope(); + SOAPEnvelope envelope = new SOAPEnvelope(msgContext.getSOAPConstants()); msgContext.setRequestMessage(new Message(envelope)); RPCElement body = new RPCElement(methodNS, method, params); 1.4 +4 -0 xml-axis/java/src/org/apache/axis/enum/Use.java Index: Use.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/enum/Use.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Use.java 11 Dec 2002 22:38:17 -0000 1.3 +++ Use.java 21 Jan 2003 17:01:14 -0000 1.4 @@ -71,9 +71,11 @@ private static final Type type = new Type(); + public static final String ENCODED12_STR = "encoded12"; public static final String ENCODED_STR = "encoded"; public static final String LITERAL_STR = "literal"; + public static final Use ENCODED12 = type.getUse(ENCODED12_STR); public static final Use ENCODED = type.getUse(ENCODED_STR); public static final Use LITERAL = type.getUse(LITERAL_STR); @@ -117,6 +119,8 @@ Constants.URI_DEFAULT_SOAP_ENC), new Use(1, LITERAL_STR, Constants.URI_LITERAL_ENC), + new Use(2, ENCODED12_STR, + Constants.URI_SOAP12_ENC), }); }