Hello Thank you for taking the time to have a look at this:
I have followed the link you provided, and I have had a look at some of the
tools. I really need some documentation in order to use them. I manage to start
one of them (C# tool) and it failed two tests, but none specific to this field
(but was related to the class the field was in). But again, I don't really know
if I tested for the right stuff.
I checked the WSDL using SOAP-UI and it found no faults.
I also used wsdl-analyzer.com and it also found no problems.
I checked the WSDL using wsimport from Metro jaxws 4.0.0 and it claimed there
was 5 errors (1 not being able to look up q1:PersonInformationDTO, and 4
regarding the faults having namespace assigned).
I then generated the java files anew using cxf wsdl2java but used the -validate
flag, yet no warnings/errors were shown. In the PersonInformationDTO.class file
there is this comment:
/**
* <p>Java class for PersonInformationDTO complex type.
*
* <p>The following schema fragment specifies the expected content contained
within this class.
*
* <pre>
* <complexType name="PersonInformationDTO">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="GeneralPractitioner"
type="{http://schemas.datacontract.org/2004/07/CGM.DGWS.SSNLookup.Service.Models}GeneralPractitionerDTO"
minOccurs="0"/>
* <element name="PersonInformationProtected"
type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* <element name="PersonName"
type="{http://schemas.datacontract.org/2004/07/CGM.DGWS.SSNLookup.Service.Models}PersonNameDTO"
minOccurs="0"/>
* <element name="PostalAddress"
type="{http://schemas.datacontract.org/2004/07/CGM.DGWS.SSNLookup.Service.Models}PostalAddressDTO"
minOccurs="0"/>
* <element name="PublicHealthInsurance"
type="{http://schemas.datacontract.org/2004/07/CGM.DGWS.SSNLookup.Service.Models}PublicHealthInsuranceDTO"
minOccurs="0"/>
* <element name="SocialSecurityNumber"
type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
The point here is that wsdl2java clearly knows about the Boolean and the
correct schema for it.
I'll try to look further in to the validators you linked and hope to figure out
which one to use and how to set it up.
Thank you,
Bernhard
-----Original Message-----
From: Łukasz Dywicki <[email protected]>
Sent: 19 January 2023 16:38
To: [email protected]
Subject: Re: wsdl2java generated code doesn't handle boolean correctly?
This email originated from outside of CGM. Please do not click links or open
attachments unless you know the sender and know the content is safe.
Hello Ege,
The ObjectFactory class which is generated out of schema includes complex types
such as PersonInformationDTO, PersonNameDTO and so on.
All types which are of scalar (boolean, int, ...) and derivative (simple
content, scalar type extensions) will be ommited as they are mapped to
aproprieate Java types which are part of Java standard library.
You can find in generated code you pasted:
protected Boolean personInformationProtected
This is scalar value coming out of xs:boolean type defined in schema.
To me it looks like schema processing or JAXB runtime misses namespace
information. Error you pasted indicate *<{}PersonInformationProtected>* which
does not include namespace.
Can you confirm if service you work with is compatible with WS-I Basic Profile?
You can use publicly available tools from Web Services Interopability
Organization:
https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fws-i.org%2Fdeliverables%2Ftestingtools.html&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kV6%2B1ThneW8aN2BRHt3kvlpqW5zcnbsBzhqBnL5jd%2BE%3D&reserved=0
Kind regards,
Łukasz
--
Code-House
https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fcode-house.org%2F&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nTXYEPp7DNeAgOUxzVKPiPNpGYISwAJQECr466pgtMA%3D&reserved=0
On 19.01.2023 13:16, Ege, Bernhard wrote:
> 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="https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschemas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved=0"
>
> xmlns:xs="https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3zzLceOAaFY2XMBuXyFeoP1u%2BuyEDtAmqrQ3BzgrF4w%3D&reserved=0"
>
>
> xmlns:tns="https://deu01.safelinks.protection.outlook.com/?url=http%3A
> %2F%2Fschemas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&
> data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e42659
> 55f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8e
> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C30
> 00%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D
> &reserved=0">
> <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="https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschemas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved=0"
>
>
> xmlns:i="https://deu01.safelinks.protection.outlook.com/?url=http%3A%2
> F%2Fwww.w3.org%2F2001%2FXMLSchema-instance&data=05%7C01%7C%7C4c434722d
> 90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C6
> 38097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoi
> V2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hR4KqLvgH
> PkVBOsnSyIwJORf3zwwMVk9LT4iwfjXxVk%3D&reserved=0">
> <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 =
> "https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsche
> mas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved=0",
> type = JAXBElement.class, required = false)
> protected JAXBElement<GeneralPractitionerDTO> generalPractitioner;
> @XmlElement(name = "PersonInformationProtected")
> * protected Boolean personInformationProtected;*
> @XmlElementRef(name = "PersonName", namespace =
> "https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsche
> mas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved=0",
> 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:"https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2
> Fschemas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=
> 05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03
> c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIj
> oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C
> %7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&rese
> rved=0", local:"PersonInformationProtected"). Expected elements are
> <{https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsch
> emas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=05%7
> C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329
> c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC
> 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%
> 7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved
> =0}SocialSecurityNumber>,<{https://deu01.safelinks.protection.outlook.
> com/?url=http%3A%2F%2Fschemas.datacontract.org%2F2004%2F07%2FMyProject
> .Service.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C6
> 9602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown
> %7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
> XVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQ
> PKy4ARymbncZI%3D&reserved=0}PersonName>,*<{}PersonInformationProtected
> >*,<{https://deu01.safelinks.protection.outlook.com/?url=http%3A%2F%2F
> schemas.datacontract.org%2F2004%2F07%2FMyProject.Service.Models&data=0
> 5%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602cf4a76e4265955f03c
> 329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjo
> iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%
> 7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reser
> ved=0}PostalAddress>,<{https://deu01.safelinks.protection.outlook.com/
> ?url=http%3A%2F%2Fschemas.datacontract.org%2F2004%2F07%2FMyProject.Ser
> vice.Models&data=05%7C01%7C%7C4c434722d90549fba00e08dafa332ff4%7C69602
> cf4a76e4265955f03c329c50608%7C0%7C0%7C638097394999968083%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI
> 6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig%2BsgYJOcBoapeAR4dk7gQPKy4
> ARymbncZI%3D&reserved=0}PublicHealthInsurance>,<{https://deu01.safelin
> ks.protection.outlook.com/?url=http%3A%2F%2Fschemas.datacontract.org%2
> F2004%2F07%2FMyProject.Service.Models&data=05%7C01%7C%7C4c434722d90549
> fba00e08dafa332ff4%7C69602cf4a76e4265955f03c329c50608%7C0%7C0%7C638097
> 394999968083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luM
> zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e%2FlsAw%2Foig
> %2BsgYJOcBoapeAR4dk7gQPKy4ARymbncZI%3D&reserved=0}GeneralPractitioner>
> at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.j
> ava:931)
> at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.j
> ava: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(PhaseIntercepto
> rChain.java:307)
> at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:829)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRe
> sponseInternal(HTTPConduit.java:1726)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRe
> sponse(HTTPConduit.java:1592)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HT
> TPConduit.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$MessageSenderEndin
> gInterceptor.handleMessage(MessageSenderInterceptor.java:63)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
> rChain.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
