You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Mark Rave (JIRA)" <ax...@ws.apache.org> on 2006/02/14 15:39:29 UTC

[jira] Created: (AXIS-2406) Non-nillable elements of a group are required even if the group itself is not.

Non-nillable elements of a group are required even if the group itself is not.
------------------------------------------------------------------------------

         Key: AXIS-2406
         URL: http://issues.apache.org/jira/browse/AXIS-2406
     Project: Apache Axis
        Type: Bug
  Components: WSDL processing  
    Versions: 1.3    
 Environment: Windows 2000, Java 1.4.2_05
    Reporter: Mark Rave


Issue stems from the use of the <xsd:group ref=""> inside of complex type.  What seems to be happening is that even though the group as a whole is nillable the elements of the group are not.  Instead of creating a subtype WSDL2Java places the group elements along with other elements in the type at the same level which means that both elements of the group are required which is not what I want.  I understand that WSDL2Java can't simply create a subtype of its own since that would generate incorrect XML.   I have attached a sample wsdl and code that shows the problem.  I am using the -W option with WSDL2Java.  

File sample.wsdl:

<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:msgs="urn:company:specification:product:service:xml:schema:1" xmlns:ws="urn:company:specification:product:service:xml:wsdl:1" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:company:specification:product:service:xml:wsdl:1">
	<wsdl:types>
		<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:company:specification:product:service:xml:wsdl:1" xmlns:msgs="urn:company:specification:product:service:xml:schema:1" xmlns:ws="urn:company:specification:product:service:xml:wsdl:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
			<xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>
			<xsd:import namespace="urn:company:specification:product:service:xml:schema:1" schemaLocation="./msg.xsd"/>
			<xsd:element name="update">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element ref="msgs:updateReq"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
		</xsd:schema>
	</wsdl:types>
	
	<wsdl:message name="updateIn">
		<wsdl:part name="update" element="ws:update"/>
	</wsdl:message>
	<wsdl:message name="updateOut">
		<wsdl:part name="updateRes" element="msgs:updateRes"/>
	</wsdl:message>

	<wsdl:portType name="EProduct">
		<wsdl:operation name="update">
			<wsdl:input name="updateInput" message="ws:updateIn"/>
			<wsdl:output name="updateOutput" message="ws:updateOut"/>
		</wsdl:operation>
	
	</wsdl:portType>
	
	<wsdl:binding name="EProductSoapBinding" type="ws:EProduct">
		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
		<wsdl:operation name="update">
			<soap:operation soapAction="urn:company:specification:product:service:xml:wsdl:1/update" style="document"/>
			<wsdl:input>
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>

	<wsdl:service name="EProductService">
		<wsdl:port name="EProductServiceSOAPPort" binding="ws:EProductSoapBinding">
			<soap:address location="http://abc.companyproduct.com/product/E-ProductService"/>
		</wsdl:port>
	</wsdl:service>

</wsdl:definitions>

File msg.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:company:specification:product:service:xml:schema:1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msgs="urn:company:specification:product:service:xml:schema:1" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
	
	<xsd:group name="sampleGroup">
		<xsd:sequence>
			<xsd:element name="id" type="xsd:string" nillable="false"/>
			<xsd:element name="type" type="xsd:string" nillable="false"/>
		</xsd:sequence>
	</xsd:group>

	<xsd:complexType name="updateReq">
		<xsd:sequence>
			<xsd:element name="test" type="xsd:string" nillable="false"/>
			<xsd:group ref="msgs:sampleGroup" minOccurs="0"/>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:element name="updateReq" type="msgs:updateReq"/>
	
	<xsd:complexType name="updateRes">
		<xsd:sequence>
			<xsd:element name="response" type="xsd:string" nillable="false"/>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:element name="updateRes" type="msgs:updateRes"/>


</xsd:schema>

File SampleTest.java:

import _1.schema.xml.service.product.specification.company.UpdateReq;
import _1.wsdl.xml.service.product.specification.company.EProduct;
import _1.wsdl.xml.service.product.specification.company.EProductService;
import _1.wsdl.xml.service.product.specification.company.EProductServiceLocator;
import _1.wsdl.xml.service.product.specification.company.Update;

public class SampleTest {
    public static void main(String[] args) {
        try {
            EProductService service = new EProductServiceLocator();
            EProduct prod = service.getEProductServiceSOAPPort();
            Update u = new Update();
            UpdateReq ur = new UpdateReq();
            ur.setTest("Test");
            //ur.setId("ID");
            //ur.setType("Type");
            u.setUpdateReq(ur);
            prod.update(u);
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
        
    }

}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira