我正在使用spring-ws 2.0.2和spring-ws-test来运行我的SOAP服务器的集成测试.我使用的方法与http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/test/server/MockWebServiceClient.html中的方法完全相同
这是我运行的代码,为了简洁而省略了预期的响应XML,因为它与问题无关.
我希望能够在响应有效负载中看到xml,但无法弄清楚如何访问它.如果我在设置响应后设置断点并检查它,我可以看到它有一个类型为SaajSoapMessage的私有messageContext.response,但我无法弄清楚如何访问它,或者是否有更好的方法来查看响应XML.
package com.example.integration;
import static org.springframework.ws.test.server.RequestCreators.*;
import static org.springframework.ws.test.server.ResponseMatchers.*;
import static org.testng.AssertJUnit.*;
import javax.xml.transform.Source;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.ws.test.server.MockWebServiceClient;
import org.springframework.ws.test.server.ResponseActions;
import org.springframework.xml.transform.StringSource;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ContextConfiguration(locations={"/transaction-test-context.xml", "/spring-web-services-servlet.xml"})
public class BaseWebServiceIntegrationTest {
@Autowired
private ApplicationContext applicationContext;
private MockWebServiceClient mockClient;
@BeforeClass(groups="integration")
public void createClient() {
assertNotNull("expected applicationContext to be non-null", applicationContext);
mockClient = MockWebServiceClient.createClient(applicationContext);
}
@Test(groups="integration")
public void proofOfConcept() {
assertNotNull("expected mockClient to be non-null", mockClient);
Source requestPayload = new StringSource(
"<s0:ListDevicesRequest " + …
Run Code Online (Sandbox Code Playgroud)