使用spring ws获取StreamResult,如下所示
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System.out);
webServiceTemplate.sendSourceAndReceiveToResult("http://someUri",
source, new SoapActionCallback("someCallBack"), result);
return result;
Run Code Online (Sandbox Code Playgroud)
我得到了结果,但我想把它提取到某种xml甚至是字符串(只是想看到内容以便生成响应).
我怎样才能做到这一点?
我要求发XmlData
在CDATA
哪个返回一个附件的SOAP请求。
使用org.springframework.oxm.jaxb.Jaxb2Marshaller
的编组与解组。
<![CDATA[<tag>Test</tag>]]>
这是我想在soap请求中发送的东西,远程服务希望它以相同的方式看到。
我已经创建了数据但是当我使用 webServiceTemplate.marshalSendAndReceive(payloadRequest, SoapActionCallback)
不知何故,有效载荷请求 xmltags 被编码并显示为
<![CDATA[<tag>Test<\tag>
由于这种编码,远程服务无法处理请求并发送
org.springframework.ws.soap.client.SoapFaultClientException: Object reference not set to an instance of an object.
我该如何解决这个问题?有什么建议!
更新:spring mvc 的 defaultHtmlEscape 作为 web.xml 中的上下文参数是否负责这种行为?
道的hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/sss.properties"/>
</bean>
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${driverClass}"/>
<property name="minPoolSize" value="${minPoolSize}"/>
<property name="maxPoolSize" value="${maxPoolSize}"/>
<property name="maxIdleTime" value="${maxIdleTime}"/>
<property name="maxStatements" value="${maxStatements}"/>
<property name="idleConnectionTestPeriod" value="${idleConnectionTestPeriod}"/>
<property name="autoCommitOnClose" value="${autoCommitOnClose}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
<property name="jdbcUrl" value="${jdbcUrl}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>ups/scanning/spss/hibernate/sss.hbm.xml</value>
.....
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hbmDialect}</prop>
<prop key="hibernate.show_sql">${hbmShowSql}</prop>
<prop key="hibernate.format_sql">${hbmFormatSql}</prop>
<prop key="hibernate.use_sql_comments">${hbmSqlComments}</prop> …
Run Code Online (Sandbox Code Playgroud) 使用Ning创建并连接到Websocket,以下是我的配置,
NettyAsyncHttpProviderConfig config = new NettyAsyncHttpProviderConfig();
config.addProperty(NettyAsyncHttpProviderConfig.USE_BLOCKING_IO, "true");
AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder()
.setAsyncHttpClientProviderConfig(config);
AsyncHttpClient client = new AsyncHttpClient(
new NettyAsyncHttpProvider(builder.build()));
AsyncHttpClient.BoundRequestBuilder requestBuilder = client.prepareGet(createUri(method))
.addHeader(HttpHeaders.Names.CONNECTION, "Upgrade")
.addHeader(HttpHeaders.Names.UPGRADE, "WebSocket");
websocket = requestBuilder.execute(new WebSocketUpgradeHandler.Builder()
.addWebSocketListener(this).build()).get();
Run Code Online (Sandbox Code Playgroud)
使用websocket发送短信,
if (websocket!=null && websocket.isOpen())
websocket.sendTextMessage(jObj.toString());// send
Run Code Online (Sandbox Code Playgroud)
onMessage()
侦听器的方法将响应添加到列表中
@Override
public void onMessage(String message) {
serverResponse.add(message);
}
Run Code Online (Sandbox Code Playgroud)
发送文本消息后,我有方法格式化响应并保存结果
result = responseFromServer();
private String responseFromServer() {
String response = null;
sleep(100);
if(!serverResponse.isEmpty())
//format the message which is added in list
return response;
}
Run Code Online (Sandbox Code Playgroud)
问题是,如果我在上面的方法中没有'sleep(100)',对于request1- response为null,对于request2,我得到response1.我希望websocket能够同步工作,这样,一旦我发送消息,就应该等待响应接收并继续前进!有什么建议!
当我在linux中启动tomcat服务器时,war文件应该自动部署webapp.当我看到localhost.log文件时,发现以下错误
SEVERE: Servlet /webapp threw load() exception
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:652)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:600)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:666)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:519)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:460)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5231)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5518)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at …
Run Code Online (Sandbox Code Playgroud)