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 "Amila Chinthaka Suriarachchi (JIRA)" <ji...@apache.org> on 2007/05/03 07:38:15 UTC
[jira] Commented: (AXIS2-2600) Code Generator should consider
namespaceprefixes defined in wsdl rather than defining ns1 when generating
code for MY_QNAME in ADB classes
[ https://issues.apache.org/jira/browse/AXIS2-2600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493283 ]
Amila Chinthaka Suriarachchi commented on AXIS2-2600:
-----------------------------------------------------
according to the xml definitions there is no need to namespace prefixed to be unique.
i.e.
<ns1:CheckServiceRequest xmlns:ns1="http://www.foo-bar.de/foo">
<ns1:id>00004711</ns1:auftragsID>
<ns1:ergebnisURI>http://www.foo-bar.de:8181/TheService/download/result00004711.xml</ns1:ergebnisURI>
</ns1:CheckServiceRequest>
is syntactically equal to
<foo:CheckServiceRequest xmlns:foo="http://www.foo-bar.de/foo">
<ns1:id>00004711</ns1:auftragsID>
<foo:ergebnisURI>http://www.foo-bar.de:8181/TheService/download/result00004711.xml</ns1:ergebnisURI>
</foo:CheckServiceRequest>
So there is no problem with the Axis2 side.
So when writting any application you should not assume the same namespaceprefix.
try something like this
XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(System.out);
request.serialize(new QName("hhtp://www.foo-bar.de/foo", "CheckServiceRequest", "foo")
, OMAbstractFactory.getSOAP11Factory(), xmlStreamWriter);
xmlStreamWriter.flush();
use your file writer instead of System.out
> Code Generator should consider namespaceprefixes defined in wsdl rather than defining ns1 when generating code for MY_QNAME in ADB classes
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: AXIS2-2600
> URL: https://issues.apache.org/jira/browse/AXIS2-2600
> Project: Axis 2.0 (Axis2)
> Issue Type: Bug
> Components: adb, codegen, om
> Affects Versions: 1.1.1
> Environment: AXIS2-1.1.1, codegen commandline (ant) ADB, jdk1.5, Tomcat 5.5, Win XP SP2
> Reporter: Ulf Heyder
> Assigned To: Amila Chinthaka Suriarachchi
>
> I have a small test WSDL (see below). I let AXIS2 Code Generator generate classes by calling
> wsdl2java -uri foo.wsdl -o foosrc -p de.theservice.axis2 -ss -ssi -g
> -t -sd -ns2p http://www.foo-bar.de/foo=de.theservice.axis2.foo
> In the created ADB bean classes the definition of QName-s look like
> public static final javax.xml.namespace.QName MY_QNAME =
> new javax.xml.namespace.QName("http://www.foo-bar.de/foo",
> "CheckServiceRequest", "ns1");
> replacing user defined namesspaceprefixes (in my example: "foo") with prefixes like ns1, ns2, ... (in my example: "ns1")
> When my client submits a "CheckService" request my service skeleton implementation has to serialize the request object to a file.
> public CheckServiceResponse CheckService(CheckServiceRequest request)
> throws CheckServiceFaultMsgException {
> OMOutputFormat omOutformat = new OMOutputFormat();
> omOutformat.setCharSetEncoding("UTF-8");
> OMDataSource omOutSource = request.getOMDataSource(
> CreateProductSelTypRequest.MY_QNAME,
> OMAbstractFactory.getOMFactory());
> OutputStream outBeanStr = new FileOutputStream(someFile);
> omOutSource.serialize(outBeanStr, omOutformat);
> outBeanStr.close();
> }
> The output file "someFile" looks like
> <ns1:CheckServiceRequest xmlns:ns1="http://www.foo-bar.de/foo">
> <ns1:id>00004711</ns1:auftragsID>
> <ns1:ergebnisURI>http://www.foo-bar.de:8181/TheService/download/result00004711.xml</ns1:ergebnisURI>
> </ns1:CheckServiceRequest>
> I use this output as input for a XSL Transformer. The problem now is that I therefor strictly need the original namespaceprefix "foo" instead of the unknown "ns1", since there are dependencies of external xml schema defining namespaceprefix "foo".
> As a workaround I tried to set the prefix when serializing the bean to file:
> OMDataSource omOutSource = request.getOMDataSource(
> new QName("hhtp://www.foo-bar.de/foo", "CheckServiceRequest", "foo"),
> OMAbstractFactory.getOMFactory());
> This didn't work.
> 1.
> CodeGen should follow the prefixes defined in wsdl. There could be a new flag to turn this beahavior on and off.
> 2.
> There should be a way to overrule the usage of the namespaceprefixes ns1, ns2, ... defined in MY_QNAME in the generated adb classes.
> ----- WSDL -------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:foo="http://www.foo-bar.de/foo"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
> name="TheService" targetNamespace="http://www.foo-bar.de/foo">
> <wsdl:types>
> <xs:schema targetNamespace="http://www.foo-bar.de/foo"
> xmlns:foo="http://www.foo-bar.de/foo">
>
> <xs:element name="CheckServiceRequest"
> type="xs:string" />
> <xs:element name="CheckServiceResponse"
> type="foo:CheckServiceResponseType" />
> <xs:element name="CheckServiceFault"
> type="xs:string" />
> <xs:complexType name="CheckServiceResponseType">
> <xs:sequence>
> <xs:element name="id"
> type="xs:string" />
> <xs:element name="resultURI"
> type="xs:anyURI" />
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
> </wsdl:types>
> <wsdl:message name="CheckServiceRequest">
> <wsdl:part element="foo:CheckServiceRequest"
> name="CheckServiceRequest" />
> </wsdl:message>
> <wsdl:message name="CheckServiceResponse">
> <wsdl:part element="foo:CheckServiceResponse"
> name="CheckServiceResponse" />
> </wsdl:message>
> <wsdl:message name="CheckServiceFaultMsg">
> <wsdl:part name="CheckServiceFault" element="foo:CheckServiceFault" />
> </wsdl:message>
> <wsdl:portType name="TheService">
> <wsdl:operation name="CheckService">
> <wsdl:input message="foo:CheckServiceRequest" />
> <wsdl:output message="foo:CheckServiceResponse" />
> <wsdl:fault name="CheckServiceFault"
> message="foo:CheckServiceFaultMsg" />
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="TheServiceSOAP" type="foo:TheService">
> <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
> <wsdl:operation name="CheckService">
> <soap:operation soapAction="CheckService" />
> <wsdl:input>
> <soap:body use="literal" />
> </wsdl:input>
> <wsdl:output>
> <soap:body use="literal" />
> </wsdl:output>
> <wsdl:fault name="CheckServiceFault">
> <soap:fault name="CheckServiceFault" use="literal" />
> </wsdl:fault>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="TheService">
> <wsdl:port binding="foo:TheServiceSOAP" name="TheServiceSOAP">
> <soap:address
> location="http://www.foo-bar.de:8181/TheService" />
> </wsdl:port>
> </wsdl:service>
> </wsdl:definitions>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org