Forums Register Login

Invalid type (xsi:type) is set when XML request is generated from web service client

+Pie Number of slices to send: Send
Hi,

I am developing a web service client using the .jar files generated using weblogic proxy.
An element in the schema is :
<xs:complexType name="EntityType">
<xs:sequence>
<!--more elements-->
<xs:element ref="Addresses" minOccurs="0" maxOccurs="1"/> <!-- Addresses -->
<!--more elements-->
</xs:complexType>


The element Addresses is referring to :

<xs:element name="Addresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" type="AddressType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="AddressType">
<xs:sequence>
<xs:element name="AddressTypeIdentifier" type="AddressTypeIdentifierType"/>
<xs:element name="AddressLine" minOccurs="0" maxOccurs="2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="30" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Municipality" minOccurs="0" maxOccurs="1"> <xs:annotation> <xs:documentation>Municipality or City</xs:documentation> </xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="30" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>

In the client this adresses element is set as :

AddressType[] addressType = new AddressType[1];
String[] addressLine = {"Lane1","Plot2"};
addressType[0]=new AddressType();
addressType[0].setAddressLineaddressLine);
addressType[0].setAddressTypeIdentifier(AddressTypeIdentifierType.Physical);
addressType[0].setCountryCode("95");
addressType[0].setMunicipality("Kolkata");
entityType.setAddresses(addressType);

When web service is called using this client the java code is generating the XML request for adreeses as :

<n5:Addresses xsi:type="n5:Addresses" xmlns:n5="http://www.pwc.com/GlobalIT/XDC/CreateEntity/CommonTypes/v10">
<n5:Address>
<n5:AddressTypeIdentifier>Physical</n5:AddressTypeIdentifier>
<n5:AddressLine>Lane1</n5:AddressLine>
<n5:AddressLine>Plot2</n5:AddressLine>
<n5:Municipality>Kolkata</n5:Municipality>
<n5:CountryCode>95</n5:CountryCode>
</n5:Address>
</n5:Addresses>

which is causing the validation error "could not find type n5:adresses".


Can any one help me on what is going wrong and what needs to be done to resolve this issue?

Thanks in advance,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,

which is causing the validation error "could not find type n5:adresses".


Addresses is spelled incorrectly. Is that your typo or is it what actually coming in your exception stack trace?

Also, can you also post your wsdl, so I can try and find your problem more easily?
+Pie Number of slices to send: Send
That is a typo.

The WSDL is


Regards,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,
It's becoming a nightmare to resolve issues with your WSDL.
For example your WSDL is missing end tag for '<xs:restriction>' as shown below.


Please post a well-formed and validated WSDL. Also, don't copy paste wsdl content from your browser as it comes with '-'s. I think you haven't gone through this link before posting your question.

I sometimes wonder our ranchers should conduct test on How To Ask Questions On JavaRanch as a part of membership .
+Pie Number of slices to send: Send
@Ruchira Ghosh: The namespace send in the request is the same as the one in your WSDL. But why is the is send in the request? It is usually send to support inheritance.
Is it possible to send the request without the xsi:type?
If I understood your original question, the web service rejects the request because of the xsi:type.
+Pie Number of slices to send: Send
Thanks Naveen and Jim.

The actual WSDL has five more services and a very big one.So I tried to reduce the size so that one can look into it easily. But sorry, I made mistake at that effort.
I am providing a fresh WSDL.

@Jim, no type is sent in request.
The request was sent like this

AddressType[] addressType = new AddressType[1];
String[] addressLine = {"Lane1","Plot2"};
addressType[0]=new AddressType();
addressType[0].setAddressLineaddressLine);
addressType[0].setAddressTypeIdentifier(AddressTypeIdentifierType.Physical);
addressType[0].setCountryCode("95");
addressType[0].setMunicipality("Kolkata");
entityType.setAddresses(addressType);



What I understand is, addresses should actually be an array of AddressType. No seperate Addresses type is declared.
But, the java code is generating the request with xsi: type="n5:Addresses".
I am totally new to this web services technology and not able to figure out how the xml request is generated from the java request.
I decompiled the soap_stub generated to see the source of it, but have not got any clue.

Thanking You,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,

Thanks Naveen and Jim


Its Naren

I am providing a fresh WSDL.


Most of the problems with web services happen due to the way how WSDL is defined. If you provide WSDL, then someone may try to give solution more efficiently.
+Pie Number of slices to send: Send
Very sorry. Don't know how I am reading the name wrongly since yesterday

Should I provide the actual WSDL? It has almost 1200 lins, so I though only the part containing this service would be sufficient as the others worked fine. So I deleted the schema and messages for the other services.
I tried to attach the actual WSDL, but was not able to find what format it accepts.
Will it be readable if I paste the 1200 lines of WSDL here?

Another problem is the service was designed few months back by some other team and already deployed in production server after being tested using SOAP UI. I am not supposed to change that service unless it is impossible to use it without the change.

Thanking You,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,
Because of javascript scripting error, I couldn't see your WSDL in my earlier post and had to ask you again . I'll take a look now.
+Pie Number of slices to send: Send
Hi Ruchira,
I tested a part my sample WSDL (containing Addresses and related elements) and I don't get xsi:type attribute. In your EntityType complex type declaration, for "Addresses" reference, try changing like this.


Because, "Addresses" complex type has already been defined as an array. So, no need to reference it with min and max occurs again!
+Pie Number of slices to send: Send
Hi Naren,

I tried running the service after deleting the minOccure and maxOccure as you suggested.

But still getting the same error

Thanking You,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,
That's not encouraging!

The change I suggested and you made has to be done anyway. Have you tried generating test request message in SOAP UI? Let me know what you'll see there. Most probably you won't see, then it must be Weblogic WSDL2Java causing the problem.
+Pie Number of slices to send: Send
Hi Naren,

In SOAP UI it never failed, before or after the change suggested by you.
But when the XML request is generated from the java client it is generated with that xsi type and not working.
I tried to develop the client using AXIS2, but it failed to generate the stub.

Thanking You,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,

That's weird! Okay, I can only suggest one more way of doing.

Instead of referring Addresses like this


Try using like this


Where AddressesType complexType is same as Addresses complexType, which you have now. But, just renamed (or you can use the same name).
+Pie Number of slices to send: Send
Thanks Naren.
I tried after putting the type. It is working.
But I am not sure if I am allowed to make that change

Something is wrong with this WSDL though they are tested Ok with SOAP UI.
It has another service which is running fine, the response is created correctly in the server side, but the client is getting a null response.
May be I'll post this in future for some help if I would not find any solution.

Thanking You,
Ruchira
+Pie Number of slices to send: Send
Hi Ruchira,
I'm glad its working.

But I am not sure if I am allowed to make that change


Don't know what circumstances you are under. But, usually when you change anything in WSDL you are expected to regenerate Stubs and because of this change, all you have to do is to change references from Address to AddressType (which anyway IDE prompts you to do) and this would be seamless for any legacy applications.

Something is wrong with this WSDL though they are tested Ok with SOAP UI.


If you are referring this particular change, then I think WSDL is right. The issue could be with weblogic web services framwork, which is different to SOAP UI.
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 11925 times.
Similar Threads
How to get element names from schema
Axis 1.4 throwing org.xml.sax.SAXException: Invalid element
WSSecurity, MTOM and TIBCO 5.6
axis
converting xsd to html
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:05:09.