Groups > Weblogic > WebLogic Webservices > xsd validation fails on wls92




xsd validation fails on wls92

xsd validation fails on wls92
Fri, 14 Dec 2007 15:22:39 -080
Hi, I hope someone can help me, it's very important! :-(

I have written a sample hello world application to test the internal soap
validation for a bigger project - it seems to work for normal complex types
(PersonType), but when I set the type as abstract and send another type that
extends PersonType (EnhancedPersonType), it fails. :(

[b]some informations:[/b]
---
I added the tag <validation-request>true</validation-request> to the
file weblogic-webservices.xml (activates the internal validation from soap
processor)

The client is generated with the clientgen ant task.

WLS is 9.2
---

[b]sending a PersonType:[/b] (correct failure)
---
  [java] Exception in thread "main" java.rmi.RemoteException:
SOAPFaultException - FaultCode
[{http://schemas.xmlsoap.org/soap/envelope/}Server] FaultString [error:
cvc-elt.2: Element
'T=PersonType@http://www.example.org/HelloService/HelloTypes/' is abstract and
cannot be used in an instance] FaultActor [null] Detail
[<detail><bea_fault:stacktrace
xmlns:bea_fault="http://www.bea.com/servers/wls70/webservice/fault/1.0.0&qu
ot;></bea_fault:stacktrace>com.bea.xml.XmlRuntimeException: error:
cvc-elt.2: Element
'T=PersonType@http://www.example.org/HelloService/HelloTypes/' is abstract and
cannot be used in an instance
     [java] 	at
com.bea.staxb.runtime.internal.FailFastErrorHandler.add(FailFastErrorHandler.jav
a:45)
---

[b]sending an EnhancedPersonType:[/b] (what's wrong here???)

---
  [java] Exception in thread "main" java.rmi.RemoteException:
SOAPFaultException - FaultCode
[{http://schemas.xmlsoap.org/soap/envelope/}Server] FaultString [error:
cvc-elt.4.2: Invalid xsi:type qname: 'hel:EnhancedPersonType'] FaultActor [null]
Detail [<detail><bea_fault:stacktrace
xmlns:bea_fault="http://www.bea.com/servers/wls70/webservice/fault/1.0.0&qu
ot;></bea_fault:stacktrace>com.bea.xml.XmlRuntimeException: error:
cvc-elt.4.2: Invalid xsi:type qname: 'hel:EnhancedPersonType'
     [java] 	at
com.bea.staxb.runtime.internal.FailFastErrorHandler.add(FailFastErrorHandler.jav
a:45)
---

[b]used wsdl;[/b]

---
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://www.example.org/HelloService/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="HelloService"
	xmlns:tps="http://www.example.org/HelloService/HelloTypes/"
	targetNamespace="http://www.example.org/HelloService/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

	<wsdl:types>
		<xsd:schema
			targetNamespace="http://www.example.org/HelloService/HelloTypes/"&g
t;

			<xsd:element name="SayHelloRequest">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="person"
							type="tps:PersonType" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:element name="SayHelloResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="greeting" type="xsd:string"
/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:complexType name="PersonType"
abstract="true">
				<xsd:attribute name="firstName" type="xsd:string"
/>
				<xsd:attribute name="lastName" type="xsd:string"
/>
			</xsd:complexType>

			<xsd:complexType name="EnhancedPersonType">
				<xsd:complexContent>
					<xsd:extension base="tps:PersonType">
						<xsd:attribute name="street" type="xsd:string"
/>
						<xsd:attribute name="city" type="xsd:string" />
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>

		</xsd:schema>
	</wsdl:types>

	<wsdl:message name="SayHelloInput">
		<wsdl:part name="body" element="tps:SayHelloRequest"
/>
	</wsdl:message>

	<wsdl:message name="SayHelloOutput">
		<wsdl:part name="boody" element="tps:SayHelloResponse"
/>
	</wsdl:message>

	<wsdl:portType name="HelloPortType">
		<wsdl:operation name="sayHello">
			<wsdl:input message="tns:SayHelloInput" />
			<wsdl:output message="tns:SayHelloOutput" />
		</wsdl:operation>
	</wsdl:portType>

	<wsdl:binding name="HelloBinding"
type="tns:HelloPortType">

		<soap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
		<wsdl:operation name="sayHello">


			<soap:operation
				soapAction="http://www.example.org/HelloService/sayHello" />
			<wsdl:input>

				<soap:body use="literal" />
			</wsdl:input>

			<wsdl:output>

				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>

	</wsdl:binding>

	<wsdl:service name="HelloService">
		<wsdl:documentation>
			WSDL File for HelloService
		</wsdl:documentation>
		<wsdl:port binding="tns:HelloBinding"
name="HelloPort">
			<soap:address
				location="http://localhost:7001/hello/HelloService" />
		</wsdl:port>
	</wsdl:service>

</wsdl:definitions>

---

[b]with the tcp/ip monitor, I see the following soap message on the wire;[/b]

---
<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Header />
	<soapenv:Body>
		<hel:SayHelloRequest
			xmlns:hel="http://www.example.org/HelloService/HelloTypes/">
			<person xsi:type="hel:EnhancedPersonType"
firstName="Simple"
				lastName="Person" />
		</hel:SayHelloRequest>
	</soapenv:Body>
</soapenv:Envelope>
---

[b]the client:[/b]

---
private void runClient(String serviceLocation) throws ServiceException,
			RemoteException {

		HelloService service = new HelloService_Impl(serviceLocation);
		HelloPortType port = service.getHelloPort();

		PersonType person = new EnhancedPersonType();
		person.setFirstName("Simple");
		person.setLastName("Person");

		SayHelloRequest request = new SayHelloRequest();
		request.setPerson(person);
		SayHelloResponse response = port.sayHello(request);
		System.out.println("response for Person: '" +
response.getGreeting()
				+ "'");
---

[b]the service implementation:[/b]

---
package org.example.www.helloservice;

import javax.jws.WebService;

import org.example.helloservice.hellotypes.EnhancedPersonType;
import org.example.helloservice.hellotypes.PersonType;
import org.example.helloservice.hellotypes.SayHelloResponse;

import weblogic.jws.*;

/**
 * HelloPortTypeImpl class implements web service endpoint interface
 * HelloPortType
 */

@WebService(serviceName = "HelloService", targetNamespace =
"http://www.example.org/HelloService/", endpointInterface =
"org.example.www.helloservice.HelloPortType")
@WLHttpTransport(contextPath = "hello", serviceUri =
"HelloService", portName = "HelloPort")
public class HelloPortTypeImpl implements HelloPortType {

	public HelloPortTypeImpl() {

	}

	public org.example.helloservice.hellotypes.SayHelloResponse sayHello(
			org.example.helloservice.hellotypes.SayHelloRequest body)

	{
Post Reply
about | contact