[ 
https://issues.apache.org/jira/browse/CXF-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506387
 ] 

jimma commented on CXF-740:
---------------------------

When the pojo class "Person" be annotated with "@XmlType(namespace = 
"http://test.common";)" can resolve this issue . 

This is because the jaxb use the default namespace to marshall these this class 
when the namesapce is not specified, so we need to annotate it with namesapce :

package common.test;
import javax.xml.bind.annotation.XmlType;
@XmlType(namespace = "http://test.common";)
public class Person {

    String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

} 




> Generate schema in wrong target namespace
> -----------------------------------------
>
>                 Key: CXF-740
>                 URL: https://issues.apache.org/jira/browse/CXF-740
>             Project: CXF
>          Issue Type: Bug
>            Reporter: jimma
>
> Use java2wsdl to generate wsdl for following class , schema elment "person" 
> in wrong targetNamespace.
> ------------Class Person---------------------------
> package common.test;
> public class Person {
>     String name;
>     public void setName(String name) {
>         this.name = name;
>     }
>     public String getName() {
>         return name;
>     }
> }
> -------Class Greeter--------
> package demo.test;
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> import javax.xml.ws.RequestWrapper;
> import javax.xml.ws.ResponseWrapper;
> import common.test.Person;
> @WebService(name = "Greeter", targetNamespace = "http://test.demo/";)
> public interface Greeter {
>     @WebMethod(operationName = "sayHi", exclude = false)
>     @ResponseWrapper(className = "demo.test.SayHiResponse", 
>                      localName = "sayHiResponse", targetNamespace = 
> "http://test.demo/";)
>     @RequestWrapper(className = "demo.test.SayHi", 
>                     localName = "sayHi", targetNamespace = 
> "http://test.demo/";)
>     void sayHi(@WebParam(targetNamespace = "http://test.common";, name = 
> "person")
>                Person person);
> }
> -----------Wrong wsdl ---------------
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="GreeterService" targetNamespace="http://test.demo/"; 
> xmlns:ns1="http://test.demo/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
>   <wsdl:types>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
> xmlns="http://test.demo/"; attributeFormDefault="unqualified" 
> elementFormDefault="unqualified" targetNamespace="http://test.demo/";>
> <xs:complexType name="person">
> <xs:sequence>
> <xs:element minOccurs="0" name="name" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="sayHi" type="sayHi"/>
> <xs:complexType name="sayHi">
> <xs:sequence>
> <xs:element minOccurs="0" name="arg0" type="person"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="sayHiResponse" type="sayHiResponse"/>
> <xs:complexType name="sayHiResponse">
> <xs:sequence/>
> </xs:complexType>
> </xs:schema>
>   </wsdl:types>
>   <wsdl:message name="sayHiResponse">
>     <wsdl:part name="parameters" element="ns1:sayHiResponse">
>     </wsdl:part>
>   </wsdl:message>
>   <wsdl:message name="sayHi">
>     <wsdl:part name="parameters" element="ns1:sayHi">
>     </wsdl:part>
>   </wsdl:message>
>   <wsdl:portType name="Greeter">
>     <wsdl:operation name="sayHi">
>       <wsdl:input name="sayHi" message="ns1:sayHi">
>     </wsdl:input>
>       <wsdl:output name="sayHiResponse" message="ns1:sayHiResponse">
>     </wsdl:output>
>     </wsdl:operation>
>   </wsdl:portType>
>   <wsdl:binding name="GreeterServiceSoapBinding" type="ns1:Greeter">
>     <soap:binding style="document" 
> transport="http://schemas.xmlsoap.org/soap/http"/>
>     <wsdl:operation name="sayHi">
>       <soap:operation soapAction="" style="document"/>
>       <wsdl:input name="sayHi">
>         <soap:body use="literal"/>
>       </wsdl:input>
>       <wsdl:output name="sayHiResponse">
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:service name="GreeterService">
>     <wsdl:port name="GreeterPort" binding="ns1:GreeterServiceSoapBinding">
>       <soap:address location="http://localhost:9090/hello"/>
>     </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.

Reply via email to