3

我正在尝试为简单的 Enpoint Web 服务编写 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 中仍然是新手。你对我的问题有什么建议吗?

4

1 回答 1

0

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/>
于 2012-12-18T23:33:44.573 回答