### Eclipse Workspace Patch 1.0 #P org.jboss.tools.ws.ui Index: src/org/jboss/tools/ws/ui/utils/SchemaUtils.java =================================================================== --- src/org/jboss/tools/ws/ui/utils/SchemaUtils.java (revision 31198) +++ src/org/jboss/tools/ws/ui/utils/SchemaUtils.java (working copy) @@ -671,7 +671,9 @@ buf.append(createXMLForJDOMElement2( jdomSchemaElement2, child )); } } - } else { + } else if (part.getTypeName() != null && isTypeBaseXSDOrSimple(part.getTypeName().getNamespaceURI(), part.getTypeName().getLocalPart())) { + buf.append('<' + part.getName() + ">?'); //$NON-NLS-1$ + } else { buf.append(createXMLForJDOMElement2( jdomSchemaElement, jdomElement )); } @@ -1075,6 +1077,14 @@ if (elemType != null && isTypeBaseXSDOrSimple(tns, elemType)) { isSimpleType = true; } + + boolean hasEnums = false; + if (element.getName().equals("simpleType")) { //$NON-NLS-1$ + String enums = getEnumerations(element); + if (enums != null && enums.trim().length() > 0) { + hasEnums = true; + } + } boolean includeTNSInRoot = false; if (rootIsQualified_ && !isQualified) { @@ -1083,6 +1093,9 @@ tnsprefix = "tns"; //$NON-NLS-1$ } else if (isQualified) { rootIsQualified_ = false; + if (tnsprefix == null) { + tnsprefix = "tns"; //$NON-NLS-1$ + } } boolean isSequence = element.getName().equals("sequence"); //$NON-NLS-1$ @@ -1116,7 +1129,7 @@ } - if (hasKids || isSimpleType) + if (hasKids || isSimpleType || hasEnums ) buf.append(">"); //$NON-NLS-1$ else buf.append("/>");//$NON-NLS-1$ @@ -1144,9 +1157,9 @@ } } - if (!isSequence && ( hasKids || isSimpleType )) { + if (!isSequence && ( hasKids || isSimpleType || hasEnums )) { // add ? for value - if (!hasKids || isSimpleType) + if (!hasKids || isSimpleType || hasEnums ) buf.append('?'); // close tag @@ -1162,6 +1175,22 @@ return buf.toString(); } + private static String getEnumerations ( org.jdom.Element element ) { + StringBuffer buf = new StringBuffer(); + List kids = element.getChildren(); + for (Iterator kidIter = kids.iterator(); kidIter.hasNext(); ) { + Element kid = (Element) kidIter.next(); + if (kid.getChildren() != null && kid.getChildren().size() > 0) { + buf.append(getEnumerations(kid)); + } + if (kid.getName().equals("enumeration")) { //$NON-NLS-1$ + String value = kid.getAttributeValue("value"); //$NON-NLS-1$ + buf.append(value + '|'); + } + } + return buf.toString(); + } + private static HashMap getDefinitionNamespaces ( Definition wsdlDefinition) { HashMap namespaceMap = new HashMap(); namespaceMap.put(SOAP_NS_URI, SOAP_PREFIX); #P org.jboss.tools.ws.ui.test Index: src/org/jboss/tools/ws/ui/test/utils/TesterWSDLUtilsTest.java =================================================================== --- src/org/jboss/tools/ws/ui/test/utils/TesterWSDLUtilsTest.java (revision 31199) +++ src/org/jboss/tools/ws/ui/test/utils/TesterWSDLUtilsTest.java (working copy) @@ -100,39 +100,66 @@ Assert.assertTrue(s1.contains("?")); String s2 = getSampleMessage("/jbide6593/original.wsdl", "gsearch_rss", "gsearch_rssSoap", "gsearch_rssSoap", "GetSearchResults"); - Assert.assertTrue(s2.contains("")); - Assert.assertTrue(s2.contains("?")); -// Assert.assertEquals(s1, s2); +// Assert.assertTrue(s2.contains("")); +// Assert.assertTrue(s2.contains("?")); + Assert.assertEquals(s1, s2); } @Test public void testJBIDE6694() { - /*STILL WORKING ON THIS ONE*/ -// String s1 = getSampleMessage("/jbide6694/ConverterPortType.wsdl", "ConverterPortType", "ConverterPortTypeImplPort", "ConverterPortTypeBinding", "convert"); -// Assert.assertTrue(s1.contains("")); -// Assert.assertTrue(s1.contains("?")); -// Assert.assertTrue(s1.contains("?")); -// Assert.assertTrue(s1.contains("?")); -// -// String s2 = getSampleMessage("/jbide6694/jbide6694.wsdl", "Converter", "ConverterPort", "ConverterBinding", "convert"); -// Assert.assertTrue(s2.contains("")); -// Assert.assertTrue(s2.contains("?")); -// Assert.assertTrue(s2.contains("?")); -// Assert.assertTrue(s2.contains("?")); + String s1 = getSampleMessage("/jbide6694/ConverterPortType.wsdl", "ConverterPortType", "ConverterPortTypeImplPort", "ConverterPortTypeBinding", "convert"); + Assert.assertTrue(s1.contains("")); + Assert.assertTrue(s1.contains("?")); + Assert.assertTrue(s1.contains("?")); + Assert.assertTrue(s1.contains("?")); + + String s2 = getSampleMessage("/jbide6694/jbide6694.wsdl", "Converter", "ConverterPort", "ConverterBinding", "convert"); + Assert.assertTrue(s2.contains("")); + Assert.assertTrue(s2.contains("?")); + Assert.assertTrue(s2.contains("?")); + Assert.assertTrue(s2.contains("?")); } @Test public void testJBIDE6865() { - /*STILL WORKING ON THIS ONE*/ -// String s1 = getSampleMessage("/jbide6865/wsdl1.wsdl", "DirectFlight", "DirectFlightSoap", "FlightAwareDirectFlight:DirectFlightSoap", "AirportInfo"); -// Assert.assertTrue(s1.contains("?")); + String s1 = getSampleMessage("/jbide6865/wsdl1.wsdl", "DirectFlight", "DirectFlightSoap", "FlightAwareDirectFlight:DirectFlightSoap", "AirportInfo"); + Assert.assertTrue(s1.contains("?")); } + + @Test + public void testJBDS1602() { + String s1 = getSampleMessage("/jbds1602/StockQuoteService.wsdl", "StockQuoteService", "StockQuoteServicePort", "tns:StockQuoteServiceBinding", "getStockQuoteBySymbol"); + Assert.assertTrue(s1.contains("")); + Assert.assertTrue(s1.contains("?")); + String s2 = getSampleMessage("/jbds1602/jb/SampleWS.wsdl", "SampleWSService", "SampleWSPort", "tns:SampleWSServiceSoapBinding", "echo"); + Assert.assertTrue(s2.contains("")); + Assert.assertTrue(s2.contains("")); + Assert.assertTrue(s2.contains("")); + Assert.assertTrue(s2.contains("?")); + } + + @Test + public void testJBIDE8770() { + String s1 = getSampleMessage("/jbide8770/parts.wsdl", "basic", "minusPort", "minusSOAP", "minusOperation"); + Assert.assertTrue(s1.contains("")); + Assert.assertTrue(s1.contains("?")); + + String s2 = getSampleMessageHeader("/jbide8770/parts.wsdl", "basic", "minusPort", "minusSOAP", "minusOperation"); + Assert.assertTrue(s2.contains("")); + Assert.assertTrue(s2.contains("?")); + } + private String getSampleMessage(String res, String service, String port, String binding, String operation) { Definition def = readWSDL(res); return SchemaUtils.getSampleSOAPInputMessage(def, service, port, binding, operation); } + private String getSampleMessageHeader(String res, String service, String port, String binding, String operation) { + Definition def = readWSDL(res); + return SchemaUtils.getSampleSOAPMessageHeader(def, service, port, binding, operation); + } + private Definition readWSDL(String path) { try { URL url = SchemaUtils.class.getResource(path).toURI().toURL(); Index: resources/jbide8770/parts.wsdl =================================================================== --- resources/jbide8770/parts.wsdl (revision 0) +++ resources/jbide8770/parts.wsdl (revision 0) @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +