Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java Sun Dec 17 22:34:08 2017 @@ -19,6 +19,8 @@ package org.apache.axis2.json.gson.factory; +import org.apache.axis2.AxisFault; +import org.apache.ws.commons.schema.utils.XmlSchemaRef; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaComplexType; @@ -52,7 +54,7 @@ public class XmlNodeGenerator { public XmlNodeGenerator() { } - private void processSchemaList() { + private void processSchemaList() throws AxisFault { // get the operation schema and process. XmlSchema operationSchema = getXmlSchema(elementQname); XmlSchemaElement messageElement = operationSchema.getElementByName(elementQname.getLocalPart()); @@ -81,7 +83,7 @@ public class XmlNodeGenerator { } } - private void processElement(XmlSchemaElement element, XmlNode parentNode , XmlSchema schema) { + private void processElement(XmlSchemaElement element, XmlNode parentNode , XmlSchema schema) throws AxisFault { String targetNamespace = schema.getTargetNamespace(); XmlNode xmlNode; QName schemaTypeName = element.getSchemaTypeName(); @@ -106,11 +108,34 @@ public class XmlNodeGenerator { xmlNode = new XmlNode(element.getName(), targetNamespace, false, (element.getMaxOccurs() == 1 ? false : true), schemaType.getQName().getLocalPart()); parentNode.addChildToList(xmlNode); processSchemaType(schemaType, xmlNode, schema); + }else if (element.getRef() != null) { + // Handle ref element + XmlSchemaRef xmlSchemaRef = element.getRef(); + QName targetQname = xmlSchemaRef.getTargetQName(); + if (targetQname == null) { + throw new AxisFault("target QName is null while processing ref:" + element.getName()); + } + getXmlSchema(targetQname); + xmlNode = new XmlNode(targetQname.getLocalPart(), targetNamespace, false, (element.getMaxOccurs() != 1), targetQname.getLocalPart()); + parentNode.addChildToList(xmlNode); + if (("http://www.w3.org/2001/XMLSchema").equals(targetQname.getNamespaceURI())) { + } else { + XmlSchema schemaOfType; + // see whether Schema type is in the same schema + XmlSchemaType childSchemaType = schema.getTypeByName(targetQname.getLocalPart()); + if (childSchemaType == null) { + schemaOfType = getXmlSchema(targetQname); + childSchemaType = schemaOfType.getTypeByName(targetQname.getLocalPart()); + } else { + schemaOfType = schema; + } + processSchemaType(childSchemaType, xmlNode, schemaOfType); + } } } - private void processSchemaType(XmlSchemaType xmlSchemaType , XmlNode parentNode , XmlSchema schema) { + private void processSchemaType(XmlSchemaType xmlSchemaType , XmlNode parentNode , XmlSchema schema) throws AxisFault { if (xmlSchemaType instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType)xmlSchemaType; XmlSchemaParticle particle = complexType.getParticle(); @@ -162,9 +187,13 @@ public class XmlNodeGenerator { } - public XmlNode getMainXmlNode() { + public XmlNode getMainXmlNode() throws AxisFault { if (mainXmlNode == null) { - processSchemaList(); + try { + processSchemaList(); + } catch (AxisFault axisFault) { + throw new AxisFault("Error while creating intermeidate xml structure ", axisFault); + } } return mainXmlNode; }
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/gson/axis2.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/gson/axis2.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/gson/axis2.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/gson/axis2.xml Sun Dec 17 22:34:08 2017 @@ -239,7 +239,7 @@ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/> <transportSender name="http" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> @@ -248,7 +248,7 @@ </transportSender> <transportSender name="https" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> </transportSender> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/json/axis2.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/json/axis2.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/json/axis2.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-repository/json/axis2.xml Sun Dec 17 22:34:08 2017 @@ -126,7 +126,7 @@ class="org.apache.axis2.transport.http.SOAPMessageFormatter"/> <messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/> - <messageFormatter contentType="application/json/badgerfish" + <messageFormatter contentType="application/json+badgerfish" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/> <messageFormatter contentType="text/javascript" class="org.apache.axis2.json.JSONMessageFormatter"/> @@ -140,7 +140,7 @@ <messageBuilders> <messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/> - <messageBuilder contentType="application/json/badgerfish" + <messageBuilder contentType="application/json+badgerfish" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/> <messageBuilder contentType="text/javascript" class="org.apache.axis2.json.JSONOMBuilder"/> @@ -183,12 +183,12 @@ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/> <transportSender name="http" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> </transportSender> <transportSender name="https" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> </transportSender> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-resources/custom_schema/testSchema_2.xsd URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-resources/custom_schema/testSchema_2.xsd?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-resources/custom_schema/testSchema_2.xsd (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test-resources/custom_schema/testSchema_2.xsd Sun Dec 17 22:34:08 2017 @@ -20,10 +20,10 @@ --> -<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" -targetNamespace="http://test.json.axis2.apache.org" -xmlns="http://test.json.axis2.apache.org" -elementFormDefault="qualified"> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.json.axis2.apache.org" +xmlns="http://test.json.axis2.apache.org" xmlns:ns1="http://test.json.axis2.apache.org/employee" +xmlns:tns="http://test.json.axis2.apache.org" elementFormDefault="qualified"> + <xs:import namespace="http://test.json.axis2.apache.org/employee" schemaLocation="test-resources/custom_schema/testSchema_3.xsd"></xs:import> <xs:element name="echoPerson"> <xs:complexType> @@ -49,4 +49,23 @@ elementFormDefault="qualified"> </xs:sequence> </xs:complexType> + <xs:element name="Offices" type="tns:Offices"></xs:element> + + <xs:complexType name="Offices"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Office" type="tns:Office"></xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="Office"> + <xs:sequence> + <xs:element name="phone" nillable="true" type="xs:string"></xs:element> + <xs:element name="officeCode" nillable="true" type="xs:integer"></xs:element> + <xs:element ref="ns1:Employees"></xs:element> + <xs:element name="country" nillable="true" type="xs:string"></xs:element> + <xs:element name="city" nillable="true" type="xs:string"></xs:element> + </xs:sequence> + </xs:complexType> + + </xs:schema> \ No newline at end of file Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/Echo.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/Echo.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/Echo.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/Echo.java Sun Dec 17 22:34:08 2017 @@ -19,9 +19,7 @@ package org.apache.axis2.json; -import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMSourcedElement; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.context.MessageContext; @@ -35,8 +33,7 @@ public class Echo { public OMElement echoOM(OMElement omEle) throws AxisFault { MessageContext outMsgCtx = MessageContext.getCurrentMessageContext().getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); - Object object = outMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE); - String messageType = (String) object; + String messageType = (String)outMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE); //if the request is through GET, the message type is application/xml. otherwise don't allow //any non json specific message types @@ -45,9 +42,6 @@ public class Echo { } else if (messageType.indexOf("json") < 0) { throw new AxisFault("Type of the Received Message is not JSON"); } - OMDataSource omdataOSuce = ((OMSourcedElement) omEle).getDataSource(); - OMElement newOmEle = (OMElement) omEle.detach(); - ((OMSourcedElement) newOmEle).setDataSource(omdataOSuce); return omEle; } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONDataSourceTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONDataSourceTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONDataSourceTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONDataSourceTest.java Sun Dec 17 22:34:08 2017 @@ -19,102 +19,43 @@ package org.apache.axis2.json; -import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.util.StAXUtils; +import org.apache.axiom.om.OMAbstractFactory; import org.apache.axis2.context.MessageContext; import org.apache.axis2.description.AxisService; -import org.codehaus.jettison.json.JSONException; import org.custommonkey.xmlunit.XMLTestCase; -import org.xml.sax.SAXException; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; +import static com.google.common.truth.Truth.assertAbout; +import static org.apache.axiom.truth.xml.XMLTruth.xml; + import java.io.StringReader; public class JSONDataSourceTest extends XMLTestCase { - public void testMappedSerialize1() throws Exception { - String jsonString = getMappedJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - JSONDataSource source = getMappedDataSource(jsonString); - source.serialize(outStream, new OMOutputFormat()); - assertXMLEqual("<mapping><inner><first>test string one</first></inner><inner>test string two</inner><name>foo</name></mapping>", - outStream.toString("utf-8")); - } - - public void testMappedSerialize2() throws Exception { - String jsonString = getMappedJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - OutputStreamWriter writer = new OutputStreamWriter(outStream); - JSONDataSource source = getMappedDataSource(jsonString); - source.serialize(writer, new OMOutputFormat()); - writer.flush(); - assertXMLEqual("<mapping><inner><first>test string one</first></inner><inner>test string two</inner><name>foo</name></mapping>", - outStream.toString("utf-8")); - } - - public void testMappedSerialize3() throws Exception { - String jsonString = getMappedJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(outStream); - JSONDataSource source = getMappedDataSource(jsonString); - source.serialize(writer); - writer.flush(); - assertXMLEqual("<mapping><inner><first>test string one</first></inner><inner>test string two</inner><name>foo</name></mapping>", - outStream.toString("utf-8")); - } - - public void testBadgerfishSerialize1() throws Exception { - String jsonString = getBadgerfishJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - JSONBadgerfishDataSource source = getBadgerfishDataSource(jsonString); - source.serialize(outStream, new OMOutputFormat()); - assertXMLEqual("<p xmlns=\"http://def.ns\" xmlns:bb=\"http://other.nsb\" xmlns:aa=\"http://other.ns\"><sam att=\"lets\">555</sam></p>", - outStream.toString("utf-8")); - } - - public void testBadgerfishSerialize2() throws Exception { - String jsonString = getBadgerfishJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - OutputStreamWriter writer = new OutputStreamWriter(outStream); - JSONBadgerfishDataSource source = getBadgerfishDataSource(jsonString); - source.serialize(writer, new OMOutputFormat()); - writer.flush(); - assertXMLEqual("<p xmlns=\"http://def.ns\" xmlns:bb=\"http://other.nsb\" xmlns:aa=\"http://other.ns\"><sam att=\"lets\">555</sam></p>", - outStream.toString("utf-8")); - } - - public void testBadgerfishSerialize3() throws XMLStreamException, JSONException, IOException, - ParserConfigurationException, SAXException { - String jsonString = getBadgerfishJSONString(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(outStream); - JSONBadgerfishDataSource source = getBadgerfishDataSource(jsonString); - source.serialize(writer); - writer.flush(); - assertXMLEqual("<p xmlns=\"http://def.ns\" xmlns:bb=\"http://other.nsb\" xmlns:aa=\"http://other.ns\"><sam att=\"lets\">555</sam></p>", - outStream.toString("utf-8")); + public void testMappedSerialize() throws Exception { + JSONDataSource source = getMappedDataSource( + "{\"mapping\":{\"inner\":[{\"first\":\"test string one\"},\"test string two\"],\"name\":\"foo\"}}"); + assertAbout(xml()) + .that(OMAbstractFactory.getOMFactory().createOMElement(source)) + .hasSameContentAs( + "<mapping><inner><first>test string one</first></inner><inner>test string two</inner><name>foo</name></mapping>"); + } + + public void testBadgerfishSerialize() throws Exception { + JSONBadgerfishDataSource source = getBadgerfishDataSource( + "{\"p\":{\"@xmlns\":{\"bb\":\"http://other.nsb\",\"aa\":\"http://other.ns\",\"$\":\"http://def.ns\"},\"sam\":{\"$\":\"555\", \"@att\":\"lets\"}}}"); + assertAbout(xml()) + .that(OMAbstractFactory.getOMFactory().createOMElement(source)) + .hasSameContentAs( + "<p xmlns=\"http://def.ns\" xmlns:bb=\"http://other.nsb\" xmlns:aa=\"http://other.ns\"><sam att=\"lets\">555</sam></p>"); } private JSONBadgerfishDataSource getBadgerfishDataSource(String jsonString) { return new JSONBadgerfishDataSource(new StringReader(jsonString)); } - private String getBadgerfishJSONString() { - return "{\"p\":{\"@xmlns\":{\"bb\":\"http://other.nsb\",\"aa\":\"http://other.ns\",\"$\":\"http://def.ns\"},\"sam\":{\"$\":\"555\", \"@att\":\"lets\"}}}"; - } - private JSONDataSource getMappedDataSource(String jsonString) { MessageContext messageContext = new MessageContext(); messageContext.setAxisService(new AxisService()); return new JSONDataSource(new StringReader(jsonString), messageContext); } - - private String getMappedJSONString() { - return "{\"mapping\":{\"inner\":[{\"first\":\"test string one\"},\"test string two\"],\"name\":\"foo\"}}"; - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java Sun Dec 17 22:34:08 2017 @@ -27,12 +27,11 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axis2.Constants; -import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.testutils.UtilServer; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.apache.axis2.testutils.Axis2Server; +import org.apache.axis2.testutils.ClientHelper; +import org.junit.ClassRule; import org.junit.Test; import java.io.BufferedReader; @@ -46,22 +45,11 @@ public class JSONIntegrationTest impleme private String expectedString; - private static EndpointReference echoTargetEPR; - private static String pojoUri; + @ClassRule + public static Axis2Server server = new Axis2Server("target/repo/json"); - @BeforeClass - public static void startServer() throws Exception { - UtilServer.start("test-repository/json", "test-repository/json/axis2.xml"); - echoTargetEPR = new EndpointReference( - "http://127.0.0.1:" + UtilServer.TESTING_PORT - + "/axis2/services/EchoXMLService/echoOM"); - pojoUri = "http://127.0.0.1:" + UtilServer.TESTING_PORT + "/axis2/services/POJOService"; - } - - @AfterClass - public static void stopServer() throws Exception { - UtilServer.stop(); - } + @ClassRule + public static ClientHelper clientHelper = new ClientHelper(server); protected OMElement createEnvelope() throws Exception { OMFactory fac = OMAbstractFactory.getOMFactory(); @@ -80,16 +68,12 @@ public class JSONIntegrationTest impleme private void doEchoOM(String messageType, String httpMethod) throws Exception{ OMElement payload = createEnvelope(); - Options options = new Options(); - options.setTo(echoTargetEPR); + ServiceClient sender = clientHelper.createServiceClient("EchoXMLService"); + Options options = sender.getOptions(); options.setProperty(Constants.Configuration.MESSAGE_TYPE, messageType); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setProperty(Constants.Configuration.HTTP_METHOD, httpMethod); -// ConfigurationContext clientConfigurationContext = ConfigurationContextFactory.createDefaultConfigurationContext(); - ServiceClient sender = new ServiceClient(UtilServer.getConfigurationContext(), null); options.setAction(null); - sender.setOptions(options); - options.setTo(echoTargetEPR); OMElement result = sender.sendReceive(payload); OMElement ele = (OMElement)result.getFirstOMChild(); compareWithCreatedOMText(ele.getText()); @@ -97,7 +81,7 @@ public class JSONIntegrationTest impleme @Test public void testEchoOMWithJSONBadgerfish() throws Exception{ - doEchoOM("application/json/badgerfish", Constants.Configuration.HTTP_METHOD_POST); + doEchoOM("application/json+badgerfish", Constants.Configuration.HTTP_METHOD_POST); } @Test @@ -112,9 +96,9 @@ public class JSONIntegrationTest impleme @Test public void testPOJOServiceWithJSONBadgerfish() throws Exception { - HttpURLConnection conn = (HttpURLConnection)new URL(pojoUri).openConnection(); + HttpURLConnection conn = (HttpURLConnection)new URL(server.getEndpoint("POJOService")).openConnection(); conn.setDoOutput(true); - conn.addRequestProperty("Content-Type", "application/json/badgerfish"); + conn.addRequestProperty("Content-Type", "application/json+badgerfish"); Writer out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); // XML is: <sayHello xmlns="http://example.org"><myName>Joe</myName></sayHello> out.write("{ \"sayHello\" : { \"@xmlns\" : { \"$\" : \"http://example.org\" }, \"myName\" : { \"$\" : \"Joe\" } } }"); @@ -128,7 +112,7 @@ public class JSONIntegrationTest impleme @Test public void testPOJOServiceWithJSONMapped() throws Exception { - HttpURLConnection conn = (HttpURLConnection)new URL(pojoUri).openConnection(); + HttpURLConnection conn = (HttpURLConnection)new URL(server.getEndpoint("POJOService")).openConnection(); conn.setDoOutput(true); conn.addRequestProperty("Content-Type", "application/json"); Writer out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONTestConstants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONTestConstants.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONTestConstants.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/JSONTestConstants.java Sun Dec 17 22:34:08 2017 @@ -21,7 +21,7 @@ package org.apache.axis2.json; public interface JSONTestConstants { - public static final String CONTENT_TYPE_BADGERFISH = "application/json/badgerfish"; + public static final String CONTENT_TYPE_BADGERFISH = "application/json+badgerfish"; public static final String CONTENT_TYPE_MAPPED = "application/json"; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/GsonXMLStreamReaderTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/GsonXMLStreamReaderTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/GsonXMLStreamReaderTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/GsonXMLStreamReaderTest.java Sun Dec 17 22:34:08 2017 @@ -21,7 +21,8 @@ package org.apache.axis2.json.gson; import com.google.gson.stream.JsonReader; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.OMXMLParserWrapper; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.engine.AxisConfiguration; import org.apache.ws.commons.schema.XmlSchema; @@ -57,7 +58,7 @@ public class GsonXMLStreamReaderTest { ConfigurationContext configCtxt = new ConfigurationContext(new AxisConfiguration()); GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader); gsonXMLStreamReader.initXmlStreamReader(elementQName , schemaList , configCtxt); - StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(gsonXMLStreamReader); + OMXMLParserWrapper stAXOMBuilder = OMXMLBuilderFactory.createStAXOMBuilder(gsonXMLStreamReader); OMElement omElement = stAXOMBuilder.getDocumentElement(); String actual = omElement.toString(); inputStream.close(); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java Sun Dec 17 22:34:08 2017 @@ -19,37 +19,19 @@ package org.apache.axis2.json.gson; -import org.apache.axis2.testutils.UtilServer; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.RequestEntity; -import org.apache.commons.httpclient.methods.StringRequestEntity; -import org.junit.After; +import org.apache.axis2.testutils.Axis2Server; import org.junit.Assert; -import org.junit.Before; +import org.junit.ClassRule; import org.junit.Test; -import java.io.IOException; - - public class JSONXMLStreamAPITest { - - @Before - public void setUp()throws Exception { - UtilServer.start("target/repo", "test-repository/gson/axis2.xml"); - - } - - @After - public void tearDown()throws Exception { - UtilServer.stop(); - - } + @ClassRule + public static Axis2Server server = new Axis2Server("target/repo/gson"); @Test public void xmlStreamAPITest()throws Exception{ - String getLibURL = "http://localhost:" + UtilServer.TESTING_PORT +"/axis2/services/LibraryService/getLibrary"; - String echoLibURL = "http://localhost:" + UtilServer.TESTING_PORT +"/axis2/services/LibraryService/echoLibrary"; + String getLibURL = server.getEndpoint("LibraryService") + "getLibrary"; + String echoLibURL = server.getEndpoint("LibraryService") + "echoLibrary"; String contentType = "application/json"; String charSet = "UTF-8"; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java Sun Dec 17 22:34:08 2017 @@ -22,6 +22,7 @@ package org.apache.axis2.json.gson.facto import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaCollection; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import javax.xml.namespace.QName; @@ -34,21 +35,11 @@ import java.util.List; public class XmlNodeGeneratorTest { + static List<XmlSchema> schemaList = null; @Test public void testMainXMLNode() throws Exception { - QName elementQName = new QName("http://test.json.axis2.apache.org" ,"echoPerson"); - - String fileName = "test-resources/custom_schema/testSchema_2.xsd"; - InputStream is = new FileInputStream(fileName); - XmlSchemaCollection schemaCol = new XmlSchemaCollection(); - XmlSchema schema = schemaCol.read(new StreamSource(is)); - - List<XmlSchema> schemaList = new ArrayList<XmlSchema>(); - schemaList.add(schema); - XmlNodeGenerator xmlNodeGenerator = new XmlNodeGenerator(schemaList, elementQName); - XmlNode mainXmlNode = xmlNodeGenerator.getMainXmlNode(); Assert.assertNotNull(mainXmlNode); @@ -67,7 +58,50 @@ public class XmlNodeGeneratorTest { Assert.assertEquals("gender", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getName()); Assert.assertEquals(0, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().size()); + } + + @Test + public void testXMLNodeGenWithRefElement() throws Exception { + QName eleQName = new QName("http://test.json.axis2.apache.org", "Offices"); + XmlNodeGenerator xmlNodeGenerator = new XmlNodeGenerator(schemaList, eleQName); + XmlNode mainXmlNode = xmlNodeGenerator.getMainXmlNode(); + Assert.assertNotNull(mainXmlNode); + Assert.assertEquals(true, mainXmlNode.getChildrenList().get(0).isArray()); + Assert.assertEquals(5, mainXmlNode.getChildrenList().get(0).getChildrenList().size()); + Assert.assertEquals("Employees", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getName()); + Assert.assertEquals(false, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).isArray()); + Assert.assertEquals("Employee", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).getName()); + Assert.assertEquals(true, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).isArray()); + Assert.assertEquals(3, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).getChildrenList().size()); } + + @BeforeClass + public static void setUp() throws Exception { + InputStream is2 = null; + InputStream is3 = null; + try { + String testSchema2 = "test-resources/custom_schema/testSchema_2.xsd"; + String testSchema3 = "test-resources/custom_schema/testSchema_3.xsd"; + is2 = new FileInputStream(testSchema2); + is3 = new FileInputStream(testSchema3); + XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + XmlSchema schema2 = schemaCol.read(new StreamSource(is2)); + XmlSchema schema3 = schemaCol.read(new StreamSource(is3)); + + schemaList = new ArrayList<XmlSchema>(); + schemaList.add(schema2); + schemaList.add(schema3); + } finally { + if (is2 != null) { + is2.close(); + } + if (is3 != null) { + is3.close(); + } + } + + } + } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java Sun Dec 17 22:34:08 2017 @@ -19,31 +19,23 @@ package org.apache.axis2.json.gson.rpc; -import junit.framework.Assert; import org.apache.axis2.json.gson.UtilTest; -import org.apache.axis2.testutils.UtilServer; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.apache.axis2.testutils.Axis2Server; +import org.junit.Assert; +import org.junit.ClassRule; import org.junit.Test; public class JSONRPCIntegrationTest { + @ClassRule + public static Axis2Server server = new Axis2Server("target/repo/gson"); + String contentType = "application/json"; String charSet = "UTF-8"; - @BeforeClass - public static void startTestServer() throws Exception { - UtilServer.start("test-repository/gson", "test-repository/gson/axis2.xml"); - } - - @AfterClass - public static void stopTestServer() throws Exception { - UtilServer.stop(); - } - @Test public void testJsonRpcMessageReceiver() throws Exception { String jsonRequest = "{\"echoPerson\":[{\"arg0\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}]}"; - String echoPersonUrl = "http://localhost:" + UtilServer.TESTING_PORT +"/axis2/services/JSONPOJOService/echoPerson"; + String echoPersonUrl = server.getEndpoint("JSONPOJOService") + "echoPerson"; String expectedResponse = "{\"response\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}"; String response = UtilTest.post(jsonRequest, echoPersonUrl, contentType, charSet); Assert.assertNotNull(response); @@ -53,7 +45,7 @@ public class JSONRPCIntegrationTest { @Test public void testJsonInOnlyRPCMessageReceiver() throws Exception { String jsonRequest = "{\"ping\":[{\"arg0\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}]}"; - String echoPersonUrl = "http://localhost:" + UtilServer.TESTING_PORT +"/axis2/services/JSONPOJOService/ping"; + String echoPersonUrl = server.getEndpoint("JSONPOJOService") + "ping"; String response = UtilTest.post(jsonRequest, echoPersonUrl, contentType, charSet); Assert.assertEquals("", response); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/axis2.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/axis2.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/axis2.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/axis2.xml Sun Dec 17 22:34:08 2017 @@ -232,7 +232,7 @@ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/> <transportSender name="http" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> @@ -241,7 +241,7 @@ </transportSender> <transportSender name="https" - class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> </transportSender> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/log4j.properties URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/log4j.properties?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/log4j.properties (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/conf/log4j.properties Sun Dec 17 22:34:08 2017 @@ -23,7 +23,6 @@ log4j.rootCategory=INFO, CONSOLE # Set the enterprise logger priority to FATAL log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.de.hunsicker.jalopy.io=FATAL log4j.logger.httpclient.wire.header=FATAL log4j.logger.org.apache.commons.httpclient=FATAL @@ -37,4 +36,4 @@ log4j.appender.LOGFILE=org.apache.log4j. log4j.appender.LOGFILE.File=axis2.log log4j.appender.LOGFILE.Append=true log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n \ No newline at end of file +log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/pom.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/pom.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/pom.xml Sun Dec 17 22:34:08 2017 @@ -23,9 +23,9 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.axis2</groupId> - <artifactId>axis2-parent</artifactId> - <version>1.7.0-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> + <artifactId>axis2</artifactId> + <version>1.8.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> </parent> <artifactId>axis2-kernel</artifactId> <name>Apache Axis2 - Kernel</name> @@ -71,11 +71,7 @@ </dependency> <dependency> <groupId>org.apache.woden</groupId> - <artifactId>woden-impl-commons</artifactId> - </dependency> - <dependency> - <groupId>org.apache.woden</groupId> - <artifactId>woden-impl-dom</artifactId> + <artifactId>woden-core</artifactId> </dependency> <dependency> <groupId>commons-logging</groupId> @@ -100,8 +96,18 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-javamail_1.4_spec</artifactId> + <groupId>com.google.truth</groupId> + <artifactId>truth</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.sun.mail</groupId> + <artifactId>javax.mail</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> </dependencies> @@ -236,6 +242,7 @@ </descriptors> <finalName>test-zip</finalName> <appendAssemblyId>false</appendAssemblyId> + <attach>false</attach> </configuration> </execution> </executions> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/AxisFault.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/AxisFault.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/AxisFault.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/AxisFault.java Sun Dec 17 22:34:08 2017 @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Locale; /** * An exception which maps cleanly to a SOAP fault. @@ -230,18 +231,18 @@ public class AxisFault extends RemoteExc } if (soapFaultReason != null) { - message = soapFaultReason.getText(); + message = soapFaultReason.getFaultReasonText(Locale.ENGLISH); } if (soapFaultCode != null) { // This works the same regardless of SOAP version - faultCode = soapFaultCode.getTextAsQName(); + faultCode = soapFaultCode.getValueAsQName(); SOAPFaultSubCode subCode = soapFaultCode.getSubCode(); if (subCode != null) { faultSubCodes = new ArrayList<QName>(); while (subCode != null) { - faultSubCodes.add(subCode.getValue().getTextAsQName()); + faultSubCodes.add(subCode.getValueAsQName()); subCode = subCode.getSubCode(); } } @@ -380,7 +381,7 @@ public class AxisFault extends RemoteExc if (faultReasonList.size() >= 1) { return faultReasonList.get(0).getText(); } else if (soapFaultReason != null) { - return soapFaultReason.getText(); + return soapFaultReason.getFaultReasonText(Locale.ENGLISH); } return null; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/Constants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/Constants.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/Constants.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/Constants.java Sun Dec 17 22:34:08 2017 @@ -20,6 +20,10 @@ package org.apache.axis2; +import org.apache.axiom.om.OMXMLParserWrapper; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.TransportUtils; + /** * Class Constants */ @@ -160,7 +164,6 @@ public class Constants extends org.apach */ public static final String SINGLE_SERVICE = "singleservice"; - public static final String SERVICE_MAP = "servicemap"; public static final String SERVICE_ROOT = "serviceRoot"; public static final String SERVICE_PATH = "servicePath"; public static final String SERVICE_HANDLERS = "serviceHandlers"; @@ -194,7 +197,9 @@ public class Constants extends org.apach public static final String VALUE_TRUE = "true"; public static final String VALUE_FALSE = "false"; public static final String VALUE_OPTIONAL = "optional"; + @Deprecated public static final String TESTING_PATH = "target/test-resources/"; + @Deprecated public static final String TESTING_REPOSITORY = TESTING_PATH + "samples"; public static final char SERVICE_NAME_SPLIT_CHAR = ':'; public static final String SERVICE_GROUP_ID = "ServiceGroupId"; @@ -258,12 +263,11 @@ public class Constants extends org.apach /** - * On inbound requests, the detachable input stream can be queried to get - * the inbound length. It can also be "detached" from the inbound http stream - * to allow resources to be freed. + * The {@link OMXMLParserWrapper Axiom builder} of the message in a message context. + * + * @see TransportUtils#detachInputStream(MessageContext) */ - public static final String DETACHABLE_INPUT_STREAM = - "org.apache.axiom.om.util.DetachableInputStream"; + public static final String BUILDER = OMXMLParserWrapper.class.getName(); /** SOAP Role Configuration */ public static final String SOAP_ROLE_CONFIGURATION_ELEMENT = "SOAPRoleConfiguration"; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java Sun Dec 17 22:34:08 2017 @@ -116,6 +116,12 @@ public interface AddressingConstants { static final String REFERENCE_PARAMETER_PARAMETER = "referenceParameters"; /** + * Used to attach any <wsid:Identity> OMElement found in an EPR embedded in a WSDL to an + * AxisEndpoint object. + */ + static final String ADDRESSING_IDENTITY_PARAMETER = "addressingIdentity"; + + /** * This parameter is used to decide whether the reference parameters in an inbound request * message are to be processed or not. */ @@ -145,6 +151,8 @@ public interface AddressingConstants { static final String IDENTITY_KEY_INFO = "KeyInfo"; static final String IDENTITY_X509_DATA = "X509Data"; static final String IDENTITY_X509_CERT = "X509Certificate"; + static final String IDENTITY_SPN = "Spn"; + static final String IDENTITY_UPN = "Upn"; static final String IDENTITY_PARAMETER = "WSAddressingAndIdentity"; @@ -152,6 +160,8 @@ public interface AddressingConstants { static final QName QNAME_IDENTITY_KEY_INFO = new QName(XML_SIG_NS,IDENTITY_KEY_INFO,XML_SIG_PREFIX); static final QName QNAME_IDENTITY_X509_DATA = new QName(XML_SIG_NS,IDENTITY_X509_DATA,XML_SIG_PREFIX); static final QName QNAME_IDENTITY_X509_CERT = new QName(XML_SIG_NS,IDENTITY_X509_CERT,XML_SIG_PREFIX); + static final QName QNAME_IDENTITY_SPN = new QName(ADDRESSING_IDENTITY_NS, IDENTITY_SPN, ADDRESSING_IDENTITY_PREFIX); + static final QName QNAME_IDENTITY_UPN = new QName(ADDRESSING_IDENTITY_NS, IDENTITY_UPN, ADDRESSING_IDENTITY_PREFIX); interface Final { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingHelper.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingHelper.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingHelper.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/addressing/AddressingHelper.java Sun Dec 17 22:34:08 2017 @@ -19,10 +19,14 @@ package org.apache.axis2.addressing; +import org.apache.axiom.om.OMElement; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.deployment.DeploymentConstants; +import org.apache.axis2.description.AxisBinding; import org.apache.axis2.description.AxisDescription; +import org.apache.axis2.description.AxisEndpoint; import org.apache.axis2.description.AxisOperation; import org.apache.axis2.description.Parameter; import org.apache.axis2.util.LoggingControl; @@ -328,5 +332,52 @@ public class AddressingHelper { } } } - } + } + + /** + * @param endpoint + * The endpoint to check for a + * {@link AddressingConstants#ADDRESSING_IDENTITY_PARAMETER}. Must not be + * <code>null</code> + * @return The Addressing identity OMElement ({@link AddressingConstants#QNAME_IDENTITY}) if + * such is configured on the specified <code>endpoint</code> or its <code>binding</code> + * , or <code>null</code> if not available. This will normally be available if the + * service was created from a WSDL which contains a WS-Addressing endpoint reference + * with an <wsid:Identity> extension either on the port or corresponding binding. + */ + public static OMElement getAddressingIdentityParameterValue(AxisEndpoint endpoint) { + OMElement identityElement = (OMElement) endpoint.getParameterValue(AddressingConstants.ADDRESSING_IDENTITY_PARAMETER); + + //unwrap identity element if wrapped in a parameter element + //NB: in revision 1371373 wrapping of parameter value when parsing parameters from services.xml has been removed + if (identityElement != null && identityElement.getLocalName().equals(DeploymentConstants.TAG_PARAMETER)) { + identityElement = identityElement.getFirstElement(); + } + + if (identityElement != null) { + if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { + log.debug(String.format("getAddressingIdentityParameterValue: %s parameter from AxisEndpoint '%s': %s", AddressingConstants.ADDRESSING_IDENTITY_PARAMETER, + endpoint.getName(), identityElement.toString())); + } + + return identityElement; + } + + AxisBinding binding = endpoint.getBinding(); + if (binding != null) { + identityElement = (OMElement) binding.getParameterValue(AddressingConstants.ADDRESSING_IDENTITY_PARAMETER); + } + + //unwrap identity element if wrapped in a parameter element + if (identityElement != null && identityElement.getLocalName().equals(DeploymentConstants.TAG_PARAMETER)) { + identityElement = identityElement.getFirstElement(); + } + + if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { + log.debug(String.format("getAddressingIdentityParameterValue: %s parameter from AxisBinding '%s': %s", AddressingConstants.ADDRESSING_IDENTITY_PARAMETER, + binding.getName(), identityElement == null ? "N/A" : identityElement.toString())); + } + + return identityElement; + } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/ApplicationXMLBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/ApplicationXMLBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/ApplicationXMLBuilder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/ApplicationXMLBuilder.java Sun Dec 17 22:34:08 2017 @@ -22,7 +22,6 @@ package org.apache.axis2.builder; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMXMLParserWrapper; -import org.apache.axiom.om.util.DetachableInputStream; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; @@ -49,13 +48,8 @@ public class ApplicationXMLBuilder imple SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope(); if (inputStream != null) { try { - // Apply a detachable inputstream. This can be used later - // to (a) get the length of the incoming message or (b) - // free transport resources. - DetachableInputStream is = new DetachableInputStream(inputStream); - messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is); - PushbackInputStream pushbackInputStream = new PushbackInputStream(is); + PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream); int b; if ((b = pushbackInputStream.read()) > 0) { pushbackInputStream.unread(b); @@ -63,6 +57,7 @@ public class ApplicationXMLBuilder imple BuilderUtil.createPOXBuilder(pushbackInputStream, (String) messageContext.getProperty( Constants.Configuration.CHARACTER_SET_ENCODING)); + messageContext.setProperty(Constants.BUILDER, builder); OMElement documentElement = builder.getDocumentElement(true); SOAPBody body = soapEnvelope.getBody(); body.addChild(documentElement); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/Builder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/Builder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/Builder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/Builder.java Sun Dec 17 22:34:08 2017 @@ -22,6 +22,7 @@ package org.apache.axis2.builder; import org.apache.axiom.om.OMElement; import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.util.MessageProcessorSelector; import java.io.InputStream; @@ -30,7 +31,7 @@ import java.io.InputStream; * Message builders are used by {@link org.apache.axis2.transport.TransportListener} * implementations to process the raw payload of the message and turn it into SOAP. * Transports should use - * {@link org.apache.axis2.builder.BuilderUtil#getBuilderFromSelector(String, MessageContext)} + * {@link MessageProcessorSelector#getMessageBuilder(String, MessageContext)} * to select the message builder appropriate for the content type of the message. */ public interface Builder { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Sun Dec 17 22:34:08 2017 @@ -29,10 +29,7 @@ import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMText; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.om.OMXMLParserWrapper; -import org.apache.axiom.om.impl.builder.StAXBuilder; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; import org.apache.axiom.om.util.StAXParserConfiguration; -import org.apache.axiom.om.util.StAXUtils; import org.apache.axiom.soap.SOAP11Constants; import org.apache.axiom.soap.SOAP12Constants; import org.apache.axiom.soap.SOAPBody; @@ -41,7 +38,6 @@ import org.apache.axiom.soap.SOAPEnvelop import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPModelBuilder; import org.apache.axiom.soap.SOAPProcessingException; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.context.MessageContext; @@ -59,19 +55,10 @@ import org.apache.axis2.wsdl.WSDLConstan import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.ws.commons.schema.XmlSchemaAll; -import org.apache.ws.commons.schema.XmlSchemaComplexType; -import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaParticle; -import org.apache.ws.commons.schema.XmlSchemaSequence; -import org.apache.ws.commons.schema.XmlSchemaSequenceMember; -import org.apache.ws.commons.schema.XmlSchemaType; +import org.apache.ws.commons.schema.*; import javax.activation.DataHandler; import javax.xml.namespace.QName; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -161,7 +148,7 @@ public class BuilderUtil { XmlSchemaAll sequence = (XmlSchemaAll) particle; // now we need to know some information from the binding operation. - for (XmlSchemaSequenceMember sequenceMember : sequence.getItems()) { + for (XmlSchemaAllMember sequenceMember : sequence.getItems()) { XmlSchemaElement innerElement = (XmlSchemaElement) sequenceMember; QName qName = innerElement.getQName(); @@ -267,22 +254,6 @@ public class BuilderUtil { } /** - * @deprecated Please use {@link #createPOXBuilder(InputStream, String)} to enable usage of non - * standard Axiom implementations. - */ - public static StAXBuilder getPOXBuilder(InputStream inStream, String charSetEnc) - throws XMLStreamException { - StAXBuilder builder; - // We use the StAXParserConfiguration.SOAP here as well because we don't want to allow - // document type declarations (that potentially reference external entities), even - // in plain XML messages. - XMLStreamReader xmlreader = - StAXUtils.createXMLStreamReader(StAXParserConfiguration.SOAP, inStream, charSetEnc); - builder = new StAXOMBuilder(xmlreader); - return builder; - } - - /** * Create a builder suitable for an XML message. This method uses * {@link StAXParserConfiguration#SOAP} to disallow document type declarations (that potentially * reference external entities). @@ -464,35 +435,7 @@ public class BuilderUtil { return value; } - public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext, - InputStream inStream, String contentTypeString, - boolean isSOAP) - throws OMException, XMLStreamException, FactoryConfigurationError { - StAXBuilder builder = null; - XMLStreamReader streamReader; - - Attachments attachments = createAttachmentsMap(msgContext, inStream, contentTypeString); - String charSetEncoding = getCharSetEncoding(attachments.getRootPartContentType()); - - if ((charSetEncoding == null) - || "null".equalsIgnoreCase(charSetEncoding)) { - charSetEncoding = MessageContext.UTF_8; - } - msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, - charSetEncoding); - - streamReader = StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream(), charSetEncoding); - - // Setting the Attachments map to new SwA API - msgContext.setAttachmentMap(attachments); - - String soapEnvelopeNamespaceURI = getEnvelopeNamespace(contentTypeString); - - return MessageProcessorSelector.getAttachmentBuilder(msgContext, attachments, streamReader, soapEnvelopeNamespaceURI, isSOAP); - - } - - protected static Attachments createAttachmentsMap(MessageContext msgContext, + public static Attachments createAttachmentsMap(MessageContext msgContext, InputStream inStream, String contentTypeString) { boolean fileCacheForAttachments = isAttachmentsCacheEnabled(msgContext); @@ -611,27 +554,6 @@ public class BuilderUtil { } /** - * Utility method to get a StAXBuilder - * - * @param in an InputStream - * @return a StAXSOAPModelBuilder for the given InputStream - * @throws XMLStreamException - * @deprecated If some one really need this method, please shout. - */ - public static StAXBuilder getBuilder(Reader in) throws XMLStreamException { - XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in); - return new StAXSOAPModelBuilder(xmlreader, null); - } - - /** - * @deprecated Please use {@link OMXMLBuilderFactory#createOMBuilder(InputStream)} instead. - */ - public static StAXBuilder getBuilder(InputStream inStream) throws XMLStreamException { - XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream); - return new StAXOMBuilder(xmlReader); - } - - /** * Create a SOAP model builder. This method delegates to * {@link OMXMLBuilderFactory#createSOAPModelBuilder(InputStream, String)} but generates * additional logging if an error occurs. @@ -659,132 +581,11 @@ public class BuilderUtil { } /** - * @deprecated Please use {@link #createSOAPModelBuilder(InputStream, String)} to enable usage - * of non standard Axiom implementations. - */ - public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) - throws XMLStreamException { - XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc); - try { - return new StAXSOAPModelBuilder(xmlReader); - } catch (OMException e) { - log.info("OMException in getSOAPBuilder", e); - try { - log.info("Remaining input stream :[" + - new String(IOUtils.toByteArray(inStream), charSetEnc) + "]"); - } catch (IOException e1) { - // Nothing here? - } - throw e; - } - } - - /** - * @deprecated Please use {@link #createSOAPModelBuilder(InputStream, String)} to enable usage - * of non standard Axiom implementations. - */ - public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException { - XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream); - try { - return new StAXSOAPModelBuilder(xmlReader); - } catch (OMException e) { - log.info("OMException in getSOAPBuilder", e); - try { - log.info("Remaining input stream :[" + - new String(IOUtils.toByteArray(inStream)) + "]"); - } catch (IOException e1) { - // Nothing here? - } - throw e; - } - } - - /** - * @deprecated Please use {@link #createSOAPModelBuilder(InputStream, String)} to enable usage - * of non standard Axiom implementations. - */ - public static StAXBuilder getSOAPBuilder(InputStream inStream, String charSetEnc) - throws XMLStreamException { - XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc); - try { - return new StAXSOAPModelBuilder(xmlReader); - } catch (OMException e) { - log.info("OMException in getSOAPBuilder", e); - try { - log.info("Remaining input stream :[" + - new String(IOUtils.toByteArray(inStream), charSetEnc) + "]"); - } catch (IOException e1) { - // Nothing here? - } - throw e; - } - } - - public static StAXBuilder getBuilder(SOAPFactory soapFactory, InputStream in, String charSetEnc) - throws XMLStreamException { - StAXBuilder builder; - XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in, charSetEnc); - builder = new StAXOMBuilder(soapFactory, xmlreader); - return builder; - } - - /** - * Initial work for a builder selector which selects the builder for a given message format - * based on the the content type of the recieved message. content-type to builder mapping can be - * specified through the Axis2.xml. - * - * @param type content-type - * @param msgContext the active MessageContext - * @return the builder registered against the given content-type - * @throws AxisFault + * @deprecated Use {@link MessageProcessorSelector#getMessageBuilder(String, MessageContext)}. */ public static Builder getBuilderFromSelector(String type, MessageContext msgContext) throws AxisFault { - boolean useFallbackBuilder = false; - AxisConfiguration configuration = - msgContext.getConfigurationContext().getAxisConfiguration(); - Parameter useFallbackParameter = configuration.getParameter(Constants.Configuration.USE_DEFAULT_FALLBACK_BUILDER); - if (useFallbackParameter !=null){ - useFallbackBuilder = JavaUtils.isTrueExplicitly(useFallbackParameter.getValue(),useFallbackBuilder); - } - Builder builder = configuration.getMessageBuilder(type,useFallbackBuilder); - if (builder != null) { - // Check whether the request has a Accept header if so use that as the response - // message type. - // If thats not present, - // Setting the received content-type as the messageType to make - // sure that we respond using the received message serialization format. - - Object contentNegotiation = configuration - .getParameterValue(Constants.Configuration.ENABLE_HTTP_CONTENT_NEGOTIATION); - if (JavaUtils.isTrueExplicitly(contentNegotiation)) { - Map transportHeaders = - (Map)msgContext.getProperty(MessageContext.TRANSPORT_HEADERS); - if (transportHeaders != null) { - String acceptHeader = (String)transportHeaders.get(HTTPConstants.HEADER_ACCEPT); - if (acceptHeader != null) { - int index = acceptHeader.indexOf(";"); - if (index > 0) { - acceptHeader = acceptHeader.substring(0, index); - } - String[] strings = acceptHeader.split(","); - for (String string : strings) { - String accept = string.trim(); - // We dont want dynamic content negotoatin to work on text.xml as its - // ambiguos as to whether the user requests SOAP 1.1 or POX response - if (!HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(accept) && - configuration.getMessageFormatter(accept) != null) { - type = string; - break; - } - } - } - } - } - - msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type); - } - return builder; + return MessageProcessorSelector.getMessageBuilder(type, msgContext); } public static void validateSOAPVersion(String soapNamespaceURIFromTransport, Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/DataSourceBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/DataSourceBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/DataSourceBuilder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/DataSourceBuilder.java Sun Dec 17 22:34:08 2017 @@ -29,13 +29,13 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import org.apache.axiom.attachments.ByteArrayDataSource; -import org.apache.axiom.attachments.impl.BufferUtils; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMOutputFormat; +import org.apache.axiom.util.io.IOUtils; import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; @@ -51,7 +51,7 @@ public class DataSourceBuilder implement byte[] bytes; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - BufferUtils.inputStream2OutputStream(inputStream, baos); + IOUtils.copy(inputStream, baos, -1); baos.flush(); bytes = baos.toByteArray(); } catch (IOException e) { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java Sun Dec 17 22:34:08 2017 @@ -47,6 +47,7 @@ public class MTOMBuilder implements MIME messageContext.setAttachmentMap(attachments); SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments); + messageContext.setProperty(Constants.BUILDER, builder); OMDocument document = builder.getDocument(); String charsetEncoding = document.getCharsetEncoding(); if (charsetEncoding == null) { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java Sun Dec 17 22:34:08 2017 @@ -23,7 +23,6 @@ import org.apache.axiom.attachments.Atta import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.om.OMXMLParserWrapper; -import org.apache.axiom.om.util.DetachableInputStream; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; @@ -40,16 +39,11 @@ public class SOAPBuilder implements MIME String charSetEncoding = (String) messageContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); - // Apply a detachable inputstream. This can be used later - // to (a) get the length of the incoming message or (b) - // free transport resources. - DetachableInputStream is = new DetachableInputStream(inputStream); - messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is); - // createSOAPModelBuilder takes care of configuring the underlying parser to // avoid the security issue described in CVE-2010-1632 - OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(is, + OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(inputStream, charSetEncoding); + messageContext.setProperty(Constants.BUILDER, builder); SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement(); BuilderUtil .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/client/FaultMapKey.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/client/FaultMapKey.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/client/FaultMapKey.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/client/FaultMapKey.java Sun Dec 17 22:34:08 2017 @@ -25,8 +25,8 @@ import javax.xml.namespace.QName; public class FaultMapKey { - private QName elementQname; - private String operationName; + private final QName elementQname; + private final String operationName; public FaultMapKey(QName elementQname, String operationName) { this.elementQname = elementQname; @@ -39,8 +39,8 @@ public class FaultMapKey { boolean isEqual = false; if (obj instanceof FaultMapKey){ FaultMapKey faultMapKey = (FaultMapKey) obj; - isEqual = this.elementQname.equals(faultMapKey.getElementQname()) && - this.operationName.equals(faultMapKey.getOperationName()); + isEqual = this.elementQname.equals(faultMapKey.elementQname) && + this.operationName.equals(faultMapKey.operationName); } return isEqual; } @@ -48,20 +48,4 @@ public class FaultMapKey { public int hashCode() { return this.elementQname.hashCode() + this.operationName.hashCode(); } - - public QName getElementQname() { - return elementQname; - } - - public void setElementQname(QName elementQname) { - this.elementQname = elementQname; - } - - public String getOperationName() { - return operationName; - } - - public void setOperationName(String operationName) { - this.operationName = operationName; - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/MessageContext.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/MessageContext.java Sun Dec 17 22:34:08 2017 @@ -21,7 +21,6 @@ package org.apache.axis2.context; import org.apache.axiom.attachments.Attachments; import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.util.DetachableInputStream; import org.apache.axiom.soap.SOAP11Constants; import org.apache.axiom.soap.SOAP12Constants; import org.apache.axiom.soap.SOAPEnvelope; @@ -52,6 +51,7 @@ import org.apache.axis2.description.Modu import org.apache.axis2.description.Parameter; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.description.TransportOutDescription; +import org.apache.axis2.description.WSDL2Constants; import org.apache.axis2.engine.AxisConfiguration; import org.apache.axis2.engine.AxisError; import org.apache.axis2.engine.Handler; @@ -1220,24 +1220,6 @@ public class MessageContext extends Abst } /** - * @return inbound content length of 0 - */ - public long getInboundContentLength() throws IOException { - // If there is an attachment map, the Attachments keep track - // of the inbound content length. - if (attachments != null) { -// return attachments.getContentLength(); - } - - // Otherwise the length is accumulated by the DetachableInputStream. - DetachableInputStream dis = - (DetachableInputStream) getProperty(Constants.DETACHABLE_INPUT_STREAM); - if (dis != null) { - return dis.length(); - } - return 0; - } - /** * @return Returns boolean. */ public boolean isServerSide() { @@ -1773,12 +1755,16 @@ public class MessageContext extends Abst * @return attachment */ public Attachments getAttachmentMap() { - if (attachments == null) { + return getAttachmentMap(true); + } + + public Attachments getAttachmentMap(boolean create) { + if (attachments == null && create) { attachments = new Attachments(); } return attachments; } - + /** * Adds an attachment to the attachment Map of this message context. This * attachment gets serialised as a MIME attachment when sending the message @@ -4320,4 +4306,49 @@ public class MessageContext extends Abst public void setFailureReason(Exception failureReason) { this.failureReason = failureReason; } + + /** + * @return Identifies and returns the service endpoint for this message context. The method will + * use the following steps to identify the endpoint: + * <ul> + * <li>If a non-null {@link AxisEndpoint} instance is set under the + * {@link WSDL2Constants#ENDPOINT_LOCAL_NAME ENDPOINT_LOCAL_NAME} message context + * property, return it</li> + * <li>If a non-null {@link #getAxisService() axisService} instance is set and it + * specifies {@link AxisService#isClientSide() clientSide=true}, retrieve the endpoint + * which matches its {@link AxisService#getEndpointName() enpointName}</li> + * <li>else, return <code>null</code></li> + * </ul> + */ + public AxisEndpoint findEndpoint() { + AxisEndpoint endpoint = (AxisEndpoint) getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME); + + final String methodName = "findEnpoint()"; + if (endpoint != null) { + if (log.isDebugEnabled()) { + log.debug(String.format("%s:%s - identified endpoint from property '%s': %s", getLogIDString(), methodName, WSDL2Constants.ENDPOINT_LOCAL_NAME, endpoint.getName())); + } + + return endpoint; + } + + if (axisService == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("%s:%s - no service set, cannot identify endpoint", getLogIDString(), methodName)); + } + + return null; + } + + if (!axisService.isClientSide()) { + if (log.isWarnEnabled()) { + log.warn(String.format("%s:%s - no '%s' property set and serverSide=true, cannot uniquely identify endpoint for service: ", getLogIDString(), methodName, WSDL2Constants.ENDPOINT_LOCAL_NAME, axisService.getName())); + } + return null; + } + + //on client-side, the default endpoint name is the one the AxisService was created with + String endpointName = axisService.getEndpointName(); + return axisService.getEndpoint(endpointName); + } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java Sun Dec 17 22:34:08 2017 @@ -19,11 +19,16 @@ package org.apache.axis2.context.externalize; +import org.apache.axiom.attachments.Attachments; +import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMOutputFormat; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.om.OMXMLParserWrapper; +import org.apache.axiom.om.impl.MTOMConstants; +import org.apache.axiom.om.util.StAXParserConfiguration; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; import org.apache.axis2.builder.BuilderUtil; import org.apache.axis2.context.MessageContext; import org.apache.axis2.transport.MessageFormatter; @@ -38,6 +43,9 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.OutputStream; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.stream.XMLStreamException; + /** * Utility to read/write the Message of a MessageContext * Message Object Format. @@ -169,6 +177,42 @@ public class MessageExternalizeUtils im } } + private static OMXMLParserWrapper getAttachmentsBuilder(MessageContext msgContext, + InputStream inStream, String contentTypeString, + boolean isSOAP) + throws OMException, XMLStreamException, FactoryConfigurationError { + Attachments attachments = BuilderUtil.createAttachmentsMap(msgContext, inStream, contentTypeString); + String charSetEncoding = BuilderUtil.getCharSetEncoding(attachments.getRootPartContentType()); + + if ((charSetEncoding == null) + || "null".equalsIgnoreCase(charSetEncoding)) { + charSetEncoding = MessageContext.UTF_8; + } + msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, + charSetEncoding); + + // Setting the Attachments map to new SwA API + msgContext.setAttachmentMap(attachments); + + if (isSOAP) { + if (attachments.getAttachmentSpecType().equals( + MTOMConstants.MTOM_TYPE)) { + return OMXMLBuilderFactory.createSOAPModelBuilder(attachments); + } else { + return OMXMLBuilderFactory.createSOAPModelBuilder(attachments.getRootPartInputStream(), charSetEncoding); + } + + } + // To handle REST XOP case + else { + if (attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) { + return OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments); + } else { + return OMXMLBuilderFactory.createOMBuilder(attachments.getRootPartInputStream(), charSetEncoding); + } + } + } + /** * Read the Message * @param in @@ -231,17 +275,11 @@ public class MessageExternalizeUtils im try { if (optimized) { boolean isSOAP = true; - builder = - BuilderUtil.getAttachmentsBuilder(mc, - mis, - optimizedContentType, - isSOAP); + builder = getAttachmentsBuilder(mc, mis, optimizedContentType, isSOAP); envelope = (SOAPEnvelope) builder.getDocumentElement(); - envelope.buildWithAttachments(); } else { builder = OMXMLBuilderFactory.createSOAPModelBuilder(mis, charSetEnc); envelope = (SOAPEnvelope) builder.getDocumentElement(); - envelope.build(); } } catch (Exception ex) { // TODO: what to do if can't get the XML stream reader @@ -251,9 +289,8 @@ public class MessageExternalizeUtils im + ex.getClass().getName() + " : " + ex.getLocalizedMessage() + "]", ex); envelope = null; } finally { - if (builder != null) { - builder.close(); - } + // Prepare the builder to close the underlying stream + builder.detach(); // Close the message input stream. This will ensure that the // underlying stream is advanced past the message. mis.close(); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/dataretrieval/AxisDataLocatorImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/dataretrieval/AxisDataLocatorImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/dataretrieval/AxisDataLocatorImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/kernel/src/org/apache/axis2/dataretrieval/AxisDataLocatorImpl.java Sun Dec 17 22:34:08 2017 @@ -119,11 +119,11 @@ public class AxisDataLocatorImpl impleme * caching ServiceData for Axis2 Data Locators */ private void cachingServiceData(OMElement e) { - Iterator i = e.getChildrenWithName(new QName( + Iterator<OMElement> i = e.getChildrenWithName(new QName( DRConstants.SERVICE_DATA.DATA)); String saveKey = ""; while (i.hasNext()) { - ServiceData data = new ServiceData((OMElement) i.next()); + ServiceData data = new ServiceData(i.next()); saveKey = data.getDialect(); String identifier = data.getIdentifier();
