Hi, https://localhost/MyApp/svc/soap?wsdl contains <wsdl:import location="https://localhost/MyApp/svc/soap?wsdl=MyApp.wsdl" namespace="http://mynamepsace/"> </wsdl:import>
Output of https://localhost/MyApp/svc/soap?wsdl=MyApp.wsdl <wsdl:definitions name="MyApp" targetNamespace="http://mynamespace/"> <wsdl:types> <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://mynamespace/"> .... Will run wsdl2java with -xjc-npa asap and get back to the list. Thank you for your help and prompt answer. Miguel On Mon, Dec 12, 2011 at 2:12 PM, Daniel Kulp <[email protected]> wrote: > > >> I called >> >> wsdl2java.bat 'http://myappurl:/soap?wsdl' > > > If you grab that WSDL, what does the schema in there say? Does that say > elementFormDefault="unqualified"? > > That's the import thing to make sure we get correct or the client is likely > not going to work. > > You can TRY adding -xjc-npa to the wsdl2java command to see what it will then > generate. That should result in targetNamespace="" attributes on things all > over the place. > > Dan > > > > On Monday, December 12, 2011 10:47:51 AM Miguel Martins Feitosa Filho wrote: >> Hello All CXF Users, >> >> I am using a standard setup >> cxf-2.5 >> jdk1.7.0_01 >> >> My SEI exposes REST (XML and JSON outputs) and SOAP. >> >> For SOAP: >> I am trying to use UNQUALIFIED for elementFormDefault and >> attributeFormDefault. >> >> For REST I just drop the namespace. >> >> So package-info.java looks like: >> >> @javax.xml.bind.annotation.XmlSchema( namespace=MyApp.NS, >> >> elementFormDefault = >> javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED, attributeFormDefault = >> javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED, >> > xmlns={@javax.xml.bind.annotation.XmlNs(prefix = >> MyApp.NS_QUALIFIER , namespaceURI=MyApp.NS)} >> ) >> import com.mycompany.MyApp; >> >> package com.mycompany; >> >> This generates UNQUALIFIED SOAP xml of the form: >> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> >> <soap:Body> >> <MyApp:methodResponse >> xmlns:MyApp="http://mycompany.myapp.com/"> >> <methodResponseDataList> >> <methodResponseData> >> <appName>Email</appName> >> <appRole>UPMC Email User</appRole> >> </methodResponseData> >> </methodResponseDataList> >> </MyApp:methodResponse> >> </soap:Body> >> </soap:Envelope> >> >> >> To further test the use of my application >> >> I called >> >> wsdl2java.bat 'http://myappurl:/soap?wsdl' >> >> As soon as this is working I will then call wadl2java ... :) >> >> This generated a very cool client that really makes it easy to use the >> application. >> >> Using a different IDE than I use to write my server I tried to test the >> client. >> >> When I call "method" using this client I get the following output: >> >> creating Client >> >> Dec 12, 2011 9:00:12 AM >> org.apache.cxf.service.factory.ReflectionServiceFactoryBean >> buildServiceFromWSDL >> INFO: Creating Service >> {http://www.springframework.org/schema/beans}MyApp from WSDL: >> http://localhost:8080/MyApp/soap?wsdl >> >> Dec 12, 2011 9:00:16 AM org.apache.cxf.phase.PhaseInterceptorChain >> doDefaultLogging >> WARNING: Interceptor for >> {http://www.springframework.org/schema/beans}MyApp#{http://mynamespace/}meth >> od has thrown exception, unwinding now >> org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected >> element (uri:"", local:"methodResponseData"). Expected elements are >> <{http://mynamespace/}methodResponseData> >> at >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:8 >> 24) at >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6 >> 44) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156) >> >> >> After tweaking this problem I added on the CLIENT to the >> package-info.java generated by wsdl2java for the client the following >> 2 lines: >> @javax.xml.bind.annotation.XmlSchema( namespace = "http://mynamepace", >> elementFormDefault = >> javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED, //Added this line >> attributeFormDefault = >> javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED //Added this line >> ) >> >> This had no effect. >> >> Who reads elementFormDefault? CXF or JAXB? >> >> I could change elementFormDefault and attributeFormDefault in the >> server back to QUALIFIED but that makes the xml much less readable and >> also avoids a problem that my warrant solving. >> I still find that the xml should output a xmlns="http://mynamespace" >> If this attribute is not present in a XML what does XML consider an >> unqualified xml tag's namespace to be? >> To get this output I tried adding namespace=MyApp.NS to my @XmlType or >> @XmlRootElement but still does not change the result. >> >> I also considered that the fact that my response is >> List<methodResponseData> instead of a wrapper class >> such as >> class ListOfResponseData { >> public List<methodResponseData> getItem(); >> } >> >> could be the source of the issue, but again when calling a method that >> returns only a single methodResponseData and not a List, I also get >> the same unmarshalling error. So @XMLElement Wrapper on the SEI is not >> related to the issue. >> >> My SEI has annotations of the form: >> @GET >> @Path(" thepath ") >> @WebResult(name = "methodResponseData"") >> @XmlElementWrapper(name = "ListOfMethodResponseData") >> public MethodResponseData" method() throws MyAppException; >> >> >> >> In about two weeks I can return to this problem and debug further but >> some pointers would be great on this issue and it might have a quick >> fix. >> >> Questions: >> Can I use wsdl2java and still use the UNQUALIFIED annotation in >> package-info.java? >> Should the xml contain an attribute specifying the unqualified >> namespace xmlns="http://mynamespace" somewhere. If so how can I get >> that into the output? >> >> The ability to expose to users a client jar that can be used without >> prior knowledge of XML/Transports/Protocols straightforward java code >> is a great plus even at the cost of creating a dependency on the >> CXF-2.5 runtime for their project. The more sophisticated WebService >> users will call his wsdl2java or svcutil (.net users) or other wsdl >> consumer and some may simply parse the xml/json using standard parsers >> while still others will write code to read the xml directly. This of >> course depending on their needs and level of sophistication with >> WebServices. >> >> Thanks! >> >> Miguel > -- > Daniel Kulp > [email protected] - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com
