I have created java files using wsdl2java and tried using it. While I can compile it just fine, running it results in an unexpected element error calling the (C#) webservice (or rather interpreting the result).
The field that causes problems is a boolean. It is completely left out of the autogenerated code, except in the model class itself. Small extract from the WSDL. Field in bold is the problem: <xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/MyProject.Service.Models" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/MyProject.Service.Models"> <xs:complexType name="PersonInformationDTO"> <xs:sequence> <xs:element minOccurs="0" name="GeneralPractitioner" nillable="true" type="tns:GeneralPractitionerDTO"/> <xs:element minOccurs="0" name="PersonInformationProtected" type="xs:boolean"/> <xs:element minOccurs="0" name="PersonName" nillable="true" type="tns:PersonNameDTO"/> The SOAP response (small extract): <LookupResult xmlns:a="http://schemas.datacontract.org/2004/07/MyProject.Service.Models" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:GeneralPractitioner> ... valid content ... </a:GeneralPractitioner> <a:PersonInformationProtected>false</a:PersonInformationProtected> <a:PersonName> ... valid content ... </a:PersonName> The PersonInformationDTO class has all relevant fields, but PersonInformationProtected is typed as Boolean and the rest are JAXBElement: public class PersonInformationDTO { @XmlElementRef(name = "GeneralPractitioner", namespace = "http://schemas.datacontract.org/2004/07/MyProject.Service.Models", type = JAXBElement.class, required = false) protected JAXBElement<GeneralPractitionerDTO> generalPractitioner; @XmlElement(name = "PersonInformationProtected") protected Boolean personInformationProtected; @XmlElementRef(name = "PersonName", namespace = "http://schemas.datacontract.org/2004/07/MyProject.Service.Models", type = JAXBElement.class, required = false) protected JAXBElement<PersonNameDTO> personName; ObjectFactory.class doesn't mention the field PersonInformationProtected. The files are generated like this: ./apache-cxf-3.5.5/bin/wsdl2java -d generated -p com.myproject -client 'http://url/somewhere?singleWsdl' The error when running it: org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://schemas.datacontract.org/2004/07/MyProject.Service.Models", local:"PersonInformationProtected"). Expected elements are <{http://schemas.datacontract.org/2004/07/MyProject.Service.Models}SocialSecurityNumber>,<{http://schemas.datacontract.org/2004/07/MyProject.Service.Models}PersonName>,<{}PersonInformationProtected>,<{http://schemas.datacontract.org/2004/07/MyProject.Service.Models}PostalAddress>,<{http://schemas.datacontract.org/2004/07/MyProject.Service.Models}PublicHealthInsurance>,<{http://schemas.datacontract.org/2004/07/MyProject.Service.Models}GeneralPractitioner> at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:931) at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:737) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:168) at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:829) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1726) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1592) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1389) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:689) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140) at com.sun.proxy.$Proxy41.lookup(Unknown Source) ... I hope someone can make sense of this. It may be something simple, but I am somewhat stuck. /Bernhard
smime.p7s
Description: S/MIME cryptographic signature
