当前位置: 首页>>代码示例>>Java>>正文


Java WebServiceTemplate.sendSourceAndReceiveToResult方法代码示例

本文整理汇总了Java中org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult方法的典型用法代码示例。如果您正苦于以下问题:Java WebServiceTemplate.sendSourceAndReceiveToResult方法的具体用法?Java WebServiceTemplate.sendSourceAndReceiveToResult怎么用?Java WebServiceTemplate.sendSourceAndReceiveToResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ws.client.core.WebServiceTemplate的用法示例。


在下文中一共展示了WebServiceTemplate.sendSourceAndReceiveToResult方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExpectAndReturn

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test
public void testExpectAndReturn() throws IOException
{
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectRequest("xml/control-message-test.xml").returnResponse("mock-responses/test/default-response.xml").createMock();
	assertNotNull(sender);
	assertEquals(2, sender.getRequestProcessors().size());
	
	SimpleResourceLookup lookup1 = (SimpleResourceLookup)((XmlCompareRequestValidator)extractRequestProcessor(sender,0)).getControlResourceLookup();
	assertEquals("control-message-test.xml", lookup1.getResultResource().getFilename());
	assertTrue(((XmlCompareRequestValidator)extractRequestProcessor(sender, 0)).isIgnoreWhitespace());
	
	SimpleResourceLookup lookup2 = (SimpleResourceLookup)((DefaultResponseGenerator)extractRequestProcessor(sender,1)).getResourceLookup();
	assertEquals("default-response.xml", lookup2.getResultResource().getFilename());
	
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:20,代码来源:WsMockControlTest.java

示例2: doTemplateTest

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
private void doTemplateTest(MockWebServiceMessageSender sender) throws IOException, SAXException {
	assertNotNull(sender);
	assertEquals(2, sender.getRequestProcessors().size());
	
	WsTestContextHolder.getTestContext().setAttribute("number", 2);
	
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message2.xml").getPayloadSource(), responseResult);
	
	Diff diff = XMLUnit.compareXML(new InputStreamReader(new ClassPathResource("xml/resolved-different-response.xml").getInputStream()), responseResult.toString());
	assertTrue(diff.toString(), diff.similar());
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:15,代码来源:WsMockControlTest.java

示例3: testExpectResourceNotFound

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test(expected=WebServiceIOException.class)
public void testExpectResourceNotFound() throws IOException
{
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectRequest("xml/does-not-exist.xml").returnResponse("mock-responses/test/default-response.xml").createMock();
	assertNotNull(sender);
	assertEquals(2, sender.getRequestProcessors().size());
	
	
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:14,代码来源:WsMockControlTest.java

示例4: testVerifyUri

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test(expected=WsTestException.class)
public void testVerifyUri() throws IOException, URISyntaxException
{
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectUri(new URI("http://example.com")).returnResponse("mock-responses/test/default-response.xml").createMock();
	assertNotNull(sender);
	assertEquals(2, sender.getRequestProcessors().size());
	
	
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:14,代码来源:WsMockControlTest.java

示例5: testXPathValidation

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test(expected=WsTestException.class)
public void testXPathValidation() throws IOException
{
	Map<String, String> nsMap = NS_MAP;
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectRequest("xml/control-message-test.xml")
																				.failIf("//ns:number!=1",nsMap).returnResponse("mock-responses/test/default-response.xml").createMock();
	assertNotNull(sender);
	assertEquals(3, sender.getRequestProcessors().size());
	

	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:16,代码来源:WsMockControlTest.java

示例6: testXPathAssertion

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test(expected=WsTestException.class)
public void testXPathAssertion() throws IOException
{
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectRequest("xml/control-message-test.xml")
													.assertThat("//ns:number=1",NS_MAP).returnResponse("mock-responses/test/default-response.xml").createMock();
	assertNotNull(sender);
	assertEquals(3, sender.getRequestProcessors().size());
	
	
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:15,代码来源:WsMockControlTest.java

示例7: testExpectAndThrow

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test(expected=WsTestException.class)
public void testExpectAndThrow() throws IOException
{
	MockWebServiceMessageSender sender = (MockWebServiceMessageSender)new WsMockControl().expectRequest("xml/control-message-test.xml").throwException(new WsTestException("Test error")).createMock();
	assertNotNull(sender);
	assertEquals(2, sender.getRequestProcessors().size());
	
	SimpleResourceLookup lookup1 = (SimpleResourceLookup)((XmlCompareRequestValidator)extractRequestProcessor(sender, 0)).getControlResourceLookup();
	assertEquals("control-message-test.xml", lookup1.getResultResource().getFilename());
		
	WebServiceTemplate template = new WebServiceTemplate();
	template.setMessageSender(sender);
	StringResult responseResult = new StringResult();
	template.sendSourceAndReceiveToResult(URI,createMessage("xml/valid-message.xml").getPayloadSource(), responseResult );
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:16,代码来源:WsMockControlTest.java

示例8: test

import org.springframework.ws.client.core.WebServiceTemplate; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
	
	WebServiceTemplate template = new WebServiceTemplate();
	
	SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
	messageFactory.setSoapVersion(SoapVersion.SOAP_12);
	messageFactory.afterPropertiesSet();
	template.setMessageFactory(messageFactory);
	
	CryptoFactoryBean cryptoFactory = new CryptoFactoryBean();
	cryptoFactory.setKeyStoreLocation(new ClassPathResource("keystore.jks"));
	cryptoFactory.setKeyStorePassword("password");
	cryptoFactory.afterPropertiesSet();
	Crypto crypto = cryptoFactory.getObject();
	
	SAML2CallbackHandler samlCallbackHandler = new SAML2CallbackHandler(crypto, "selfsigned");
	
	SAMLIssuerImpl issuer = new SAMLIssuerImpl();
	issuer.setIssuerCrypto(crypto);
	issuer.setIssuerKeyName("selfsigned");
	issuer.setIssuerKeyPassword("password");
	issuer.setIssuerName("selfsigned");
	issuer.setSendKeyValue(false);
	issuer.setSignAssertion(true);
	issuer.setCallbackHandler(samlCallbackHandler);
	
	Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
	securityInterceptor.setSecurementActions("Timestamp SAMLTokenSigned");
	securityInterceptor.setSecurementSignatureCrypto(crypto);
	securityInterceptor.setSecurementUsername("selfsigned");
	securityInterceptor.setSecurementPassword("password");
	securityInterceptor.setSamlIssuer(issuer);
	securityInterceptor.afterPropertiesSet();
	
	template.setInterceptors(new ClientInterceptor[] {securityInterceptor});
	template.afterPropertiesSet();
	
	Element hello = new Element("Hello", "urn:jaminh:example");
	template.sendSourceAndReceiveToResult("http://localhost:8080/spring-saml-example-war", new JDOMSource(hello), new JDOMResult());
	template.sendSourceAndReceiveToResult("http://localhost:8080/spring-saml-example-war", new JDOMSource(hello), new JDOMResult());
	template.sendSourceAndReceiveToResult("http://localhost:8080/spring-saml-example-war", new JDOMSource(hello), new JDOMResult());
	
}
 
开发者ID:jaminh,项目名称:spring-saml-example-war,代码行数:45,代码来源:HelloTest.java


注:本文中的org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。