Invalid soapenv:Envelope when using spring WebServiceTemplate - java

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!

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

A RuntimeException was generated by the RMI server

I am working on JMS and t3 protocol. JMS is configured with springframework by some properties file. Spring configuration looks like this...
I am using spring3.1.0 version.
<?xml version="1.0" encoding="windows-1252" ?>
<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.xsd">
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<bean id="testJndiEnvironment.environment" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="QueueConnectionFactory"/>
</bean>
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="TestTopic"/>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="defaultDestination" ref="destination"/>
</bean>
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="destination"/>
<property name="messageListener">
<bean id="messageListener" class="com.aires.test.jms.listener.TestMessageListener"/>
</property>
<property name="messageSelector">
<bean id="TestMessageSelector.messageSelector" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
</property>
</bean>
</beans>
this spring configuration read the message from some other server where JSMServer, Topic and connectionFactory is created.
But springcode is configured it is throwing and exception.
<Dec 20, 2016, 1:00:53,139 AM EST> <Warning> <RMI> <BEA-080003> <A RuntimeException was generated by the RMI server: 1471831785
java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators].
java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
at weblogic.security.service.SecurityServiceManagerDelegate2Impl.seal(SecurityServiceManagerDelegate2Impl.java:484)
at weblogic.security.service.SecurityServiceManagerDelegate2Impl.getSealedSubjectFromWire(SecurityServiceManagerDelegate2Impl.java:177)
at weblogic.security.service.SecurityServiceManager.getSealedSubjectFromWire(SecurityServiceManager.java:426)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:360)
at weblogic.rmi.internal.BasicServerRef.acceptRequest(BasicServerRef.java:996)
Truncated. see log file for complete stacktrace
I carefully check the providerURL , principal and subject all information are correct. I googled lot of things but could not found any solution.
could someone help to identify what I am missing here.

Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]

When I try to execute the code java -cp testThermalMap.jar ActivemqPackage.ActiveMqConsumer in command prompt I keep getting this error
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Config uration problem: Unable to locate Spring NamespaceHandler for XML schema namespa ce [http://camel.apache.org/schema/spring]
As this link says I checked my jar files but I see camel-spring-2.10.3.jar is there. can anyone tell me what are the other possible ways for this error?
Note: The same code working fine in eclipse.
EDIT: Content of mytest.xml is
<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.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd
http://camel.apache.org/schema/spring"
>
<!-- setup JMS connection factory -->
<bean id="poolConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="8"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1" />
</bean>
<!-- setup spring jms TX manager -->
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="poolConnectionFactory"/>
</bean>
<camelContext id="activeContext" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="activeMQRouter" />
</camelContext>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="poolConnectionFactory"/>
<property name="transacted" value="true"/>
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
<bean id="activeMQRouter" class="ActivemqPackage.ActiveMQRouterBuilder"/>
<bean id="activemqProcessor" class="ActivemqPackage.ActiveMQProcessor"/>

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.

WSDL file schema location can not be found

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.

Categories

Resources