Hi I have tried use package-info.java file. I created this file and put it tin the same directory containing the source files for the package. I wrote @javax.xml.bind.annotation.XmlSchema(namespace="http://ns2") package com.telvent.sensornetworkmanagement.sca;
but I didn´t obtain any results. I mean generated WSDL from Tuscany is the same. I can not see any references to "http://ns2" namespace in my new WSDL. Should Tuscany read this file? Besides, are you saying you have generated Java code using WSDL tool with my WSDL (with empty namespace)? What WSDL tool are you using? Thanks Un saludo. Santiago Miguel Aranda Rojas Telvent Interactiva Extension: 35999 "Raymond Feng" <[email protected]> "Raymond Feng" 08/05/2009 18:42 Por favor, responda a user Para: <[email protected]> cc: Asunto: Re: Wrong generated WSDL Hi, All you did was to change the targetNamespace of the first inline schema to use a non-empty namespace. That can be done by adding the package-info.java to the package as: @javax.xml.bind.annotation.XmlSchema(namespace="http://ns1") package ...; Back to the empty namespace issue, I tried two different things: 1) Use wsgen tool to generate the WSDL: The target namespace of the XML type for the JavaBean is set to the namespace for the WSDL (derived from the java package of the JAXWS SEI class). 2) Use JAXBContext.generateSchema(...) API to generate the XSD: The target namespace of the XML type is not present. Other XSDs use <xsd:import> without the "namespace" attribute to reference it. I checked the JAX-WS but I could find a clue why wsgen behaves that way. The other issue is that Eclipse WSDL editor don't seem to handle the <xsd:import> without the "namespace" attribute. Thanks, Raymond From: [email protected] Sent: Friday, May 08, 2009 5:03 AM To: [email protected] Subject: Re: Wrong generated WSDL This is my fixed WSDL. I have to change several things in order to use WSDLToJava tool. **I have added xmlns:tns1="http://ns1" in the wsdl:definitions **I have added targetNamespace="http://ns1" in the first schema ** I have added tns1: before all types defined int the first schema. For example type="tns1:device" It seems that WSDLToJava tool requires a compulsory targetNamespace in the schemas in order to find classes. <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions name="SensorNetworkManagementServiceService" targetNamespace="http://sca.sensornetworkmanagement.telvent.com/" xmlns:tns="http://sca.sensornetworkmanagement.telvent.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns1="http://ns1"> <wsdl:types> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns1" > <xs:complexType name="networkComponent"><xs:sequence><xs:element maxOccurs="unbounded" minOccurs="0" name="comprises" nillable="true" type="tns1:networkComponent"/></xs:sequence></xs:complexType> <xs:complexType name="device"><xs:complexContent><xs:extension base="tns1:networkComponent"><xs:sequence><xs:element minOccurs="0" name="brand" type="xs:string"/><xs:element name="hardwareId" type="xs:int"/><xs:element minOccurs="0" name="manufacturer" type="xs:string"/><xs:element maxOccurs="unbounded" minOccurs="0" name="measures" nillable="true" type="tns1:parameter"/><xs:element name="model" type="xs:int"/></xs:sequence></xs:extension></xs:complexContent></xs:complexType> <xs:complexType name="parameter"><xs:sequence><xs:element minOccurs="0" name="device" type="tns1:device"/><xs:element maxOccurs="unbounded" minOccurs="0" name="tests" nillable="true" type="tns1:dataTest"/></xs:sequence></xs:complexType> <xs:complexType name="dataTest"><xs:sequence><xs:element minOccurs="0" name="parameter" type="tns1:parameter"/></xs:sequence></xs:complexType> <xs:complexType final="#all" name="deviceArray"><xs:sequence><xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns1:device"/></xs:sequence></xs:complexType> </xs:schema> <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://sca.sensornetworkmanagement.telvent.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import namespace="http://ns1"/> <xs:element name="getDeviceList"> <xs:complexType/> </xs:element> <xs:element name="getDeviceListResponse"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="tns1:device"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="getDeviceList"> <wsdl:part name="getDeviceList" element="tns:getDeviceList"> </wsdl:part> </wsdl:message> <wsdl:message name="getDeviceListResponse"> <wsdl:part name="getDeviceListResponse" element="tns:getDeviceListResponse"> </wsdl:part> </wsdl:message> <wsdl:portType name="SensorNetworkManagementService"> <wsdl:operation name="getDeviceList"> <wsdl:input message="tns:getDeviceList"> </wsdl:input> <wsdl:output message="tns:getDeviceListResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SensorNetworkManagementServiceBinding" type="tns:SensorNetworkManagementService"> <SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getDeviceList"> <SOAP:operation/> <wsdl:input> <SOAP:body use="literal"/> </wsdl:input> <wsdl:output> <SOAP:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SensorNetworkManagementServiceService"> <wsdl:port name="SensorNetworkManagementServicePort" binding="tns:SensorNetworkManagementServiceBinding"> <SOAP:address location="http://192.168.3.15:8085/SensorNetworkManagementComponent"/> </wsdl:port> </wsdl:service> </wsdl:definitions> Un saludo. Santiago Miguel Aranda Rojas Telvent Interactiva Extension: 35999 [email protected] santiago.aranda 08/05/2009 13:13 Por favor, responda a user Para: [email protected] cc: Asunto: Re: Wrong generated WSDL This my WSDL. It is easier now but it is not working again. I mean I can not use it to generate Java code for a simple client with WSDLTojava tool. When I try this I have this error "Type device missing". Device is one of my classes. When I check with WSDL Eclipse tool and I have to fix manually. But I don´t know what is the best way. I would like Tuscany generates a WSDL so I could use WSDLToJava tool. I didn´t understand your sample. This step And a package-info.java. What do you mean? May I add this annotation over the package?? or add a new "package-info" class. Could you send me your sample?' @javax.xml.bind.annotation.XmlSchema(namespace="http://test") package helloworld; Thank you very much Un saludo. Santiago Miguel Aranda Rojas Telvent Interactiva Extension: 35999 Simon Laws <[email protected]> Simon Laws 07/05/2009 17:50 Por favor, responda a user Para: [email protected] cc: Asunto: Re: Wrong generated WSDL So what I find with a quick test is the following. With a bean.. package helloworld; public class ABean { protected String field1; protected String field2; An a service inteface.. public interface HelloWorldService { public String getGreetings(String name); public String getGreetingsBean(ABean bean); public String getGreetingsBeanArray(ABean[] bean); } And a package-info.java @javax.xml.bind.annotation.XmlSchema(namespace="http://test") package helloworld; I get the following generated WSDL types from Tuscany... <wsdl:types> <xs:schema targetNamespace="http://test" version="1.0" xmlns:tns="http://test" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="aBean"> <xs:sequence> <xs:element minOccurs="0" name="field1" type="xs:string" /> <xs:element minOccurs="0" name="field2" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType final="#all" name="aBeanArray"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:aBean" /> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://helloworld/ " xmlns:ns0="http://test" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import namespace="http://test" /> <xs:element name="getGreetingsBean"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="arg0" nillable="true" type="ns0:aBean" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getGreetings"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getGreetingsResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getGreetingsBeanResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getGreetingsBeanArrayResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getGreetingsBeanArray"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="arg0" nillable="true" type="ns0:aBean" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> Which validates for me. Haven't actually tries generating a client from it but it looks OK. So if you can live with this this should get you going. I'm not sure how to get vectors to work. We do need a JIRA to cover this very common case as it's a real gotcha. I note that https://issues.apache.org/jira/browse/TUSCANY-2853 was actually closed when in reality we just use a work around. I'll reopen it and add some notes. Simon
