3
我試圖寫簡單Enpoint Web服務的JUnit測試:春WS + JAXB測試
@Endpoint
public class TestWS {
@PayloadRoot(localPart = "GetAllPlayersRequest", namespace = NAMESPACE_URI)
public @ResponsePayload GetAllPlayersResponse handleGetAllPlayersRequest() {
...
}
}
我的測試看起來像:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:**/tb-ws-servlet.xml" })
public class TeambridgeWSTest extends AbstractWebServiceServerTest {
private MockWebServiceClient client;
@Autowired
public void setApplicationContex(ApplicationContext applicationContext) {
client = createClient(applicationContext);
}
@Test
public void shouldReturnAllPlayers() throws Exception {
ParametrizableRequestCreator message = withMessage("GetAllPlayersRequest.xml");
client.sendRequest(message).andExpect(message("messages="GetAllPlayersResponse.xml"));
}
}
和GetAllPlayersRequest.xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://ws.tb.company.com/schemas">
<soapenv:Header/>
<soapenv:Body>
<sch:GetAllPlayersRequest/>
</soapenv:Body>
</soapenv:Envelope>
我不知道爲什麼我得到
No endpoint mapping found for [SaajSoapMessage http://ws.tb.company.com/schemas}GetAllPlayersRequest]
我在Spring中有經驗,但在Spring WS中仍然是新的。你對我的問題有什麼建議嗎?
對於這兩個問題的答案是肯定的 – user1912592