Announcement Announcement Module
Collapse
No announcement yet.
xsd issue while generating WSDL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • xsd issue while generating WSDL

    Hi,

    I am new to Spring-WS.
    First I ran the sample Echo example on my tomcat. It is running successfully.

    Now I have creating my own webservices: I started as follows:

    1. Created response xml and created corresponding xsd using some tool.
    2. Created EndPointClass, service interface and its class.
    3. Then I put entries in web.xml and spring-ws-servlet.xml.

    but now when I am hitting the URL to generate the WSDL I am getting the following error:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customer' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Cannot resolve reference to bean 'schema' while setting bean property 'schema'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'schema' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: xsd 'class path resource [WEB-INF/customer.xsd]' does not exit
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:104)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1245)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    java.security.AccessController.doPrivileged(Native Method)

    Here is my spring-ws-servlet.xml

    Code:
        <bean id="customer" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
            <description>
                This bean definition represents a WSDL definition that is generated at runtime. It can be retrieved by
                going to /ciaservices/customer.wsdl (i.e. the bean name corresponds to the filename).
            </description>
            <property name="schema" ref="schema"/>
            <property name="portTypeName" value="Customer"/>
            <property name="locationUri" value="http://localhost:8080/ciaservices/customer"/>
        </bean>
    
        <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
            <description>
                This bean definition contains the XSD schema.
            </description>
            <property name="xsd" value="/WEB-INF/customer.xsd"/>
        </bean>
    
        <bean id="customerService" class="com.cia.ws.customer.services.CustomerProfileServiceImpl">
            <description>
                This bean is our "business" service.
            </description>
        </bean>
    
    	<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    	    <property name="mappings">
    	        <props>
    	            <prop key="{http://cia.com/customer/customersegments}CustomerProfileRequest">customerEndpoint</prop>
    	        </props>
    	    </property>
    	    <property name="interceptors">
    	        <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
    	    </property>
    	</bean>
    
       <bean id="validatingInterceptor"
              class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
            <description>
                This interceptor validates both incoming and outgoing message contents according to the 'customer.xsd' XML
                Schema file.
            </description>
            <property name="xsdSchema" ref="schema"/>
            <property name="validateRequest" value="false"/>
            <property name="validateResponse" value="true"/>
        </bean>
    Thanks

  • #2
    And here is my XSD.

    Code:
    <?xml version="1.0" encoding="utf-16"?>
    <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://cia.com/customer/customersegments"
            xmlns:tns="http://cia.com/customer/customersegments">
    
      <xsd:element name="CustomerProfileRequest" type="CustomerProfileRequestType" />
      <xsd:complexType name="CustomerProfileRequestType">
        <xsd:sequence>
          <xsd:element name="CustomerSegments" type="CustomerSegmentsType" />
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="CustomerSegmentsType">
        <xsd:sequence>
          <xsd:element name="customer-segment" type="xsd:string" />
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
    I am not clear what I am doing wrong? I there si something wrong with my XSD?

    what all are the files which Spring-WS uses for generating the WSDL?

    Comment


    • #3
      I have resolved the issue.

      Actually the problem was some jars files were missing in the build path and in the WEB-INF/lib folder.
      But this is strange if jars are missing in the Build path then it should give compilation error and if it needs that jars at runtime then I already had these in the Tomcat/lib folder. Dont know what was wrong but I simply put some spring jars into WEB-INF/lib folder and it works.

      Comment


      • #4
        needed to genearate wsdl from xsd

        Hi ,
        i am trying to generate WSDl from xsd but it is giving following error
        java.lang.NoClassDefFoundError: Could not initialize class org.springframework.ws.wsdl.wsdl11.provider.Inlini ngXsdSchemaTypesProvider
        org.springframework.ws.wsdl.wsdl11.DefaultWsdl11De finition.<init>(DefaultWsdl11Definition.java:56)
        sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
        sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
        java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
        org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:83)
        org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:61)
        org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:911)
        org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:873)
        org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:514)
        org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:485)
        java.security.AccessController.doPrivileged(Native Method)
        org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:455)
        org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
        org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:169)
        org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
        org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:170)
        org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:413)
        org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:735)
        org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:369)
        org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 32)
        org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:266 )
        org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:236)
        org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
        javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        org.apache.catalina.security.SecurityUtil$1.run(Se curityUtil.java:239)
        java.security.AccessController.doPrivileged(Native Method)
        javax.security.auth.Subject.doAsPrivileged(Subject .java:517)
        org.apache.catalina.security.SecurityUtil.execute( SecurityUtil.java:268)
        org.apache.catalina.security.SecurityUtil.doAsPriv ilege(SecurityUtil.java:157)
        org.apache.catalina.security.SecurityUtil.doAsPriv ilege(SecurityUtil.java:110)
        org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
        org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
        org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
        org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
        org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
        org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
        java.lang.Thread.run(Thread.java:619)


        the entry for sipatcher-servlet.xml is

        <bean id="humanResource" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
        <property name="schema">
        <bean class="org.springframework.xml.xsd.SimpleXsdSchema ">
        <property name="xsd" value="D:/MyAllWebApplications/WebApplication1/src/java/newPurchaseOrder.xsd"/>
        </bean>
        </property>

        <property name="portTypeName" value="humanResources"/>
        <property name="locationUri" value="http://localhost:8080/WebApplication1/humanResourceservice/"/>
        <property name="targetNamespace" value="http://xml.netbeans.org/examples/PurchaseOrder"/>
        </bean>


        and the XSD is

        <?xml version="1.0" encoding="UTF-8"?>

        <xsd:schema
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://xml.netbeans.org/examples/PurchaseOrder"
        xmlns:tns="http://xml.netbeans.org/examples/PurchaseOrder"
        elementFormDefault="qualified">

        <xsd:annotation>
        <xsd:documentation xml:lang="en">
        Purchase order schema for Example.com.
        Copyright 2000 Example.com. All rights reserved.
        </xsd:documentation>
        </xsd:annotation>

        <xsd:element name="purchaseOrder" type="tns:PurchaseOrderType"/>

        <xsd:element name="comment" type="xsd:string"/>

        <xsd:complexType name="PurchaseOrderType">
        <xsd:sequence>
        <xsd:element name="shipTo" type="tns:USAddress"/>
        <xsd:element name="billTo" type="tns:USAddress"/>
        <xsd:element ref="tns:comment" minOccurs="0"/>
        <xsd:element name="items" type="tns:Items"/>
        </xsd:sequence>
        <xsd:attribute name="orderDate" type="xsd:date"/>
        </xsd:complexType>

        <xsd:complexType name="USAddress">
        <xsd:sequence>
        <xsd:element name="name" type="xsd:string"/>
        <xsd:element name="street" type="xsd:string"/>
        <xsd:element name="city" type="xsd:string"/>
        <xsd:element name="state" type="xsd:string"/>
        <xsd:element name="zip" type="xsd:decimal"/>
        </xsd:sequence>
        <xsd:attribute name="country" type="xsd:NMTOKEN"
        fixed="US"/>
        </xsd:complexType>

        <xsd:complexType name="Items">
        <xsd:sequence>
        <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
        <xsd:sequence>
        <xsd:element name="productName" type="xsd:string"/>
        <xsd:element name="quantity">
        <xsd:simpleType>
        <xsd:restriction base="xsdositiveInteger">
        <xsd:maxExclusive value="100"/>
        </xsd:restriction>
        </xsd:simpleType>
        </xsd:element>
        <xsd:element name="USPrice" type="xsd:decimal"/>
        <xsd:element ref="tns:comment" minOccurs="0"/>
        <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attribute name="partNum" type="tns:SKU" use="required"/>
        </xsd:complexType>
        </xsd:element>
        </xsd:sequence>
        </xsd:complexType>

        <!-- Stock Keeping Unit, a code for identifying products -->
        <xsd:simpleType name="SKU">
        <xsd:restriction base="xsd:string">
        <xsdattern value="\d{3}-[A-Z]{2}"/>
        </xsd:restriction>
        </xsd:simpleType>

        </xsd:schema>


        can you please sort it out ,why it is so,thanks in advance

        Comment


        • #5
          Hi,

          It seems that InliningXsdSchemaTypesProvider is not in the claspath.
          I found this class inside spring-ws-1.5.6-all.jar.
          So please check that should be in the lib directory(if you are using tomcat) or in the classpath.

          Comment


          • #6
            yes,thanks

            thanks for your reply ,now the problem is that the wsdl is genrating now but the welcome page is not coming still the build is sucessfully formed

            Comment


            • #7
              Originally posted by ramitgulati View Post
              I have resolved the issue.

              Actually the problem was some jars files were missing in the build path and in the WEB-INF/lib folder.
              But this is strange if jars are missing in the Build path then it should give compilation error and if it needs that jars at runtime then I already had these in the Tomcat/lib folder. Dont know what was wrong but I simply put some spring jars into WEB-INF/lib folder and it works.

              Hi,

              Can you please tell me what all jars you added to solve the above issue? I am facing same problem now

              Comment

              Working...
              X