gpt4 book ai didi

junit4 - Spring WS + JAXB 测试

转载 作者:行者123 更新时间:2023-12-02 05:03:39 24 4
gpt4 key购买 nike

我正在尝试为简单的 Enpoint 网络服务编写 junit 测试:

@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还是新手。你对我的问题有什么建议吗?

最佳答案

NAMESPACE_URI 的值是多少?我想是:

private static final String NAMESPACE_URI = "http://ws.tb.company.com/schemas";

您还使用注解驱动配置了 Spring Web 服务 XML 文件,不是吗?

<context:component-scan base-package="your.package.here"/>

<sws:annotation-driven/>

关于junit4 - Spring WS + JAXB 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13931936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com