WSDL file schema location can not be found - java

While trying to use soapUI I get the error message saying it fails to load the schema request.xsd
here is how my wsdl looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:schema="http://www.myweb/xml/webservice"
xmlns:tns="http://www.myweb.com/xml/webservice"
targetNamespace="http://www.myweb.com/xml/webservice">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.myweb.com/xml/webservice"
schemaLocation="/WEB-INF/schemas/Request.xsd"/>
</xsd:schema>
and here is how my spring config file is:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="defaultEndpoint" ref="inferenceEndPoint" />
<property name="interceptors">
<list>
<ref local="validatingInterceptor" />
<ref local="payLoadInterceptor" />
</list>
</property>
</bean>
<bean id="payLoadInterceptor"
class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
<bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<description>
This interceptor validates the incoming
message contents
according to the 'Request.xsd' XML
Schema file.
</description>
<property name="schema" value="/WEB-INF/schemas/Request.xsd" />
<property name="validateRequest" value="true" />
<property name="validateResponse" value="false" />
</bean>
<bean id="mwsid" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
<constructor-arg value="/WEB-INF/spring-ws.wsdl"/>
</bean>
<bean id="inferenceEndPoint" class="com.mywebsite.ws.web.InferenceEndPoint">
<property name="messageService" ref="messageService" />
</bean>
<bean id="messageService" class="com.mywebsite.ws.service.MessageService">
<property name="inferenceService" ref="inferenceService" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schemas/Request.xsd" />
</bean>
<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService">
<property name="webServiceConfiguration" ref="playerConfiguration" />
</bean>
<!-- <bean id="inferenceConfig" class="com.mywebsite.ws.im.InferenceService">
<constructor-arg ref="playerConfiguration"/> </bean> -->
<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="playerConfiguration"
class="com.mywebsite.ws.configuration.WebServiceConfiguration"
init-method="init">
<property name="playerConfigXml" value="/WEB-INF/config/webserviceconfiguration.xml" />
<property name="executingPathResource" value="/WEB-INF" />
<property name="developmentMode" value="true" />
</bean>

I'm assuming that you're creating a new soapUI project by picking the WSDL off the local disk. The tool is reading the file and baulks when it gets to /WEB-INF/schemas/Request.xsd as this path tells it to go to the root directory and look for a directory called WEB-INF. It would also be wise to ensure consistency when discussing case (the file says Request.xsd but your problem statement says request.xsd; this matters on some platforms.
Change the import in the WSDL to:
<xsd:import namespace="http://www.myweb.com/xml/webservice"
schemaLocation="schemas/Request.xsd"/>
This assumes the XSD is in the schemas directory relative to the WSDL.

Edit your configuration files and state the schema location in full path.

Related

Getting compile error while using <context:component-scan> annotation in spring xml

I am trying to annotation to auto-wire but getting compile error, I am not able to get the error message, there is only red cross at that line in spring XML. where I am doing wrong?
spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context/">
<!--commenting it out as we are using component annotation for this class-->
<!-- <bean id="circle" class="org.devesh.learning.spring.Circle">
</bean>
-->
<bean id ="pointA" class="org.devesh.learning.spring.Point">
<property name="x" value="${pointA.pointX}"></property>
<property name="y" value="${pointA.pointY}"></property>
</bean>
<bean id = "center" class="org.devesh.learning.spring.Point">
<property name="x" value="20"></property>
<property name="y" value="0"></property>
</bean>
<bean id = "pointC" class="org.devesh.learning.spring.Point">
<qualifier value="circle related"></qualifier>
<property name="x" value="-20"></property>
<property name="y" value="0"></property>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="pointconfig.properties"></property>
</bean>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"></bean>
<context:component-scan base-package="org.devesh.learning.spring"/>
</beans>
Is it a possible typo?
as is:
xmlns:context="http://www.springframework.org/schema/context/
to be :
xmlns:context="http://www.springframework.org/schema/context

Invalid soapenv:Envelope when using spring WebServiceTemplate

I am having difficulty in calling WebService using Spring WebServiceTemplate, server response with "Fault occurred while processing."I have Soap UI project that works, I compared outgoing messages and the difference in soapenv:Envelope .
In Soap UI I have:
soapenv:Envelope
xmlns:ser="http://service.server.webservices.checkpoint.tta.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
In Spring:
SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
My spring config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="marshaller"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath"
value="com.test.checkpoint" />
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="interceptors" ref="securityInterceptor"/>
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="defaultUri" value="http://dev.checkpoint.test.com/app/services/CPWSSearchService"/>
</bean>
<bean id="securityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="securementActions" value="UsernameToken Timestamp"/>
<property name="securementUsername" value="test"/>
<property name="securementPassword" value="test"/>
<property name="securementPasswordType" value="PasswordText"/>
</bean>
</beans>
My Java Code:
PerformSearch request=new ObjectFactory().createPerformSearch();
request.setSearchUrl("Some text query");
PerformSearchResponse response= (PerformSearchResponse) client.marshalSendAndReceive(request );
Thanks in advance!

Access property values inside Spring config file

I have a simple properties file at WEB-INF/local.db.properties:
db.driverClassName=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/db_name
db.username=postgres
db.password=password
I am trying to access these properties inside of my Spring configuration file (towards the end):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="controllers" />
<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-config.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>
<util:properties id="dbProperties" location="WEB-INF/local.db.properties" />
<bean id="dbDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driverClassName}" /> <!--ERROR -->
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>
</beans>
The error is Could not load JDBC driver class [${db.driverClassName}]. The error is pretty clear to me - it is not trying to look up the property it is just using the raw string.
How do I fix this?
This is a Maven 3, Spring 4, Postgresql project.
You're not loading the properties file in Spring configuration. Add this line:
<context:property-placeholder location="classpath:/WEB-INF/local.db.properties"/>
or
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/local.db.properties"/>
</bean>
If you have several properties file, change the above configuration for:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<!-- locations, not location, check the S at the end -->
<property name="locations">
<list>
<value>
/WEB-INF/local.db.properties
</value>
<value>
<!-- Path of another properties file -->
</value>
</list>
</property>
</bean>
More info: PropertySourcesPlaceholderConfigurer
If you are using Eclipse, try right click on project -> Properties -> Java Build Path -> Source, then Add Folder or Link Source to your property files.

jaxrs with embedded jetty configuration problem

I'm trying to get a web service up using jaxrs and jetty:
This is my jaxrms.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<!-- import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /-->
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="restService" class="com.as.rover.service.rest.RestService" >
</bean>
<jaxrs:server id="jaxrsRestService" address="/rest/">
<jaxrs:serviceBeans>
<ref bean="restService" />
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
This is my jetty.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean class="com.as.rover.service.JettyManager" factory-method="getInstance" id="jettyManager">
<property name="server" >
<bean id="jetty-server" class="org.eclipse.jetty.server.Server" init-method="start" destroy-method="stop">
<property name="connectors">
<list>
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8080"/>
</bean>
</list>
</property>
<property name="handler">
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
<property name="handlers">
<list>
<ref bean="servletContextHandler"></ref>
<!--bean class="org.eclipse.jetty.server.handler.ResourceHandler">
<property name="directoriesListed" value="true"/>
<property name="welcomeFiles">
<list>
<value>index.html</value>
</list>
</property>
<property name="resourceBase" value="."/>
</bean>
<bean class="org.eclipse.jetty.server.handler.DefaultHandler"/-->
<!-- add more handlers here -->
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="web-context" class="org.eclipse.jetty.webapp.WebAppContext">
<property name="resourceBase" value="./src/main/web"></property>
<property name="contextPath" value="/services/*"></property>
<bean id="servletContextHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
<property name="contextPath" value="/" />
</bean>
<bean id="javaVersion" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="servletContextHandler"/>
<property name="targetMethod" value="addServlet"/>
<property name="arguments">
<list>
<bean class="org.eclipse.jetty.servlet.ServletHolder">
<property name="name" value="services" />
<property name="servlet">
<bean class="org.apache.cxf.transport.servlet.CXFServlet"/>
</property>
</bean>
<value>/</value>
</list>
</property>
</bean>
</beans>
My rest service class looks like this:
#Path("/test") // bind to versionnr in path
public class RestService{
#GET
public long get() {
return 1L;
}
}
Whenever I make a request to localhost:8080/services/test I get the following error message:
service not found.
I want to configure my embedded jetty server with jaxrs but it doesn't seem to work. Have I misconfigured jetty?
If you are using Spring, and all your dependencies are well placed, the only thing you need to expose a restful service is your first file.
cxf-rt-transports-http-jetty will take care of the link between your service code and the jetty server.
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<context:annotation-config />
<bean id="serviceImpl" class="com.as.rover.service.rest.serviceImpl" ></bean>
<!-- CXF -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxrs:server id="JaxrsService" address="http://localhost:6066/services">
<jaxrs:serviceBeans>
<ref bean="serviceImpl" />
</jaxrs:serviceBeans>
</jaxrs:server>
Hope it helps.

dynamic wsdl creation by spring-ws error

I want to create my wsdl by spring-ws automatically and I inserted the code below to my app context file, but I got the error;
"Cannot locate BeanDefinitionParser for element [dynamic-wsdl]"
what does that mean and what can I do? tnx
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org /schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="payloadMapping"
class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="defaultEndpoint" ref="inferenceEndPoint" />
<property name="interceptors">
<list>
<ref local="validatingInterceptor" />
<ref local="payLoadInterceptor" />
</list>
</property>
</bean>
<bean id="payLoadInterceptor"
class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
<bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<description>
This interceptor validates the incoming
message contents
according to the 'Request.xsd' XML
Schema file.
</description>
<property name="schema" value="/WEB-INF/schemas/Request.xsd" />
<property name="validateRequest" value="true" />
<property name="validateResponse" value="false" />
</bean>
<bean id="inferenceEndPoint" class="com.mywebsite.ws.web.InferenceEndPoint">
<property name="messageService" ref="messageService" />
</bean>
<bean id="messageService" class="com.mywebsite.ws.service.MessageService">
<property name="inferenceService" ref="inferenceService" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schemas/Request.xsd" />
</bean>
<sws:dynamic-wsdl id="mtwsdl"
portTypeName="mtWS"
locationUri="http://localhost:8080/mws/">
<sws:xsd location="/WEB-INF/schemas/Request.xsd" />
</sws:dynamic-wsdl>
<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService">
<property name="webServiceConfiguration" ref="playerConfiguration" />
</bean>
<!-- <bean id="inferenceConfig" class="com.mywebsite.ws.im.InferenceService">
<constructor-arg ref="playerConfiguration"/> </bean> -->
<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="playerConfiguration"
class="com.mywebsite.ws.configuration.WebServiceConfiguration"
init-method="init">
<property name="playerConfigXml" value="/WEB-INF/config/webserviceconfiguration.xml" />
<property name="executingPathResource" value="/WEB-INF" />
<property name="developmentMode" value="true" />
</bean>
Replace the first section of your appcontext where you define namespaces:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
I highly suggest to use Maven. The error you are getting is due to a missing library. In Maven you should have an entry like the following.
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
I suggest you look at the class path and also server run time path, I think you may have both (spring-ws 1.5.x and spring-ws 2.x) version's of jar files either in the compile/run time path. If that is not the case clean up the both class and run time path and add only spring-ws 2.x jar files.
As for the differences, when spring framework name space handler (WebServicesNamespaceHandler) encounters (dynamic-wsdl tag in spring context file), It will register a (DynamicWsdlBeanDefinitionParser) bean with all the properties specified in the dynamic wsdl tag. It is essentially same as you registering (DefaultWsdl11Definition) bean in spring context.

Categories

Resources