Я использую 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 в полезных данных ответа, но не могу понять, как получить доступ к Это. Если я установил точку останова после того, как был установлен ответ, и проверил его, я смогу увидеть, что у него есть частный messageContext.response типа SaajSoapMessage, но я не могу понять, как получить к нему доступ и есть ли лучший способ увидеть ответ 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(
"" +
"66:bb:be:ee:00:00:01:00 " +
" "
);
Source responsePayload = new StringSource("");
ResponseActions response = mockClient.sendRequest(withPayload(requestPayload));
response.andExpect(noFault())
.andExpect(payload(responsePayload));
}
}
отредактирован, чтобы добавить файл контекста приложения по запросу. у нас есть несколько, но один ниже предназначен для мыла.
/WEB-INF/wsdl/*Types_v*.xsd