Search in sources :

Example 1 with BookSoapService

use of org.apache.cxf.systest.jaxrs.jaxws.BookSoapService in project cxf by apache.

the class JAXRSSoapBookTest method testGetBookSoap.

@Test
public void testGetBookSoap() throws Exception {
    String wsdlAddress = "http://localhost:" + PORT + "/test/services/soap/bookservice?wsdl";
    URL wsdlUrl = new URL(wsdlAddress);
    BookSoapService service = new BookSoapService(wsdlUrl, new QName("http://books.com", "BookService"));
    BookStoreJaxrsJaxws store = service.getBookPort();
    Book book = store.getBook(new Long(123));
    assertEquals("id is wrong", book.getId(), 123);
}
Also used : BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) BookSoapService(org.apache.cxf.systest.jaxrs.jaxws.BookSoapService) QName(javax.xml.namespace.QName) URL(java.net.URL) Test(org.junit.Test)

Example 2 with BookSoapService

use of org.apache.cxf.systest.jaxrs.jaxws.BookSoapService in project cxf by apache.

the class JAXRSSoapBookTest method testGetUnqualifiedBookSoap.

@Test
public void testGetUnqualifiedBookSoap() throws Exception {
    String wsdlAddress = "http://localhost:" + PORT + "/test/services/soap-transform/bookservice?wsdl";
    BookSoapService service = new BookSoapService(new URL(wsdlAddress), new QName("http://books.com", "BookService"));
    BookStoreJaxrsJaxws store = service.getBookPort();
    TransformOutInterceptor out = new TransformOutInterceptor();
    Map<String, String> mapOut = new HashMap<>();
    // Book content (id, name) is unqualified, thus the following works
    // because JAXB will report
    // - {http://jaxws.jaxrs.systest.cxf.apache.org/}Book
    // - id
    // - name
    // and only the qualified top-level Book tag gets matched by the following
    // mapping
    mapOut.put("{http://jaxws.jaxrs.systest.cxf.apache.org/}*", "*");
    out.setOutTransformElements(mapOut);
    TransformInInterceptor in = new TransformInInterceptor();
    Map<String, String> mapIn = new HashMap<>();
    // mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
    // won't work for a case where a totally unqualified getBookResponse needs to be
    // qualified such that only the top-level getBookResponse is processed because of '*'.
    // Such a mapping would work nicely if we had say a package-info making both
    // Book id & name qualified; otherwise we need to choose what tag we need to qualify
    // mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
    // works too if the schema validation is disabled
    mapIn.put("getBookResponse", "{http://jaxws.jaxrs.systest.cxf.apache.org/}getBookResponse");
    in.setInTransformElements(mapIn);
    Client cl = ClientProxy.getClient(store);
    ((HTTPConduit) cl.getConduit()).getClient().setReceiveTimeout(10000000);
    cl.getInInterceptors().add(in);
    cl.getOutInterceptors().add(out);
    Book book = store.getBook(new Long(123));
    assertEquals("id is wrong", book.getId(), 123);
}
Also used : BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) HashMap(java.util.HashMap) BookSoapService(org.apache.cxf.systest.jaxrs.jaxws.BookSoapService) QName(javax.xml.namespace.QName) TransformOutInterceptor(org.apache.cxf.interceptor.transform.TransformOutInterceptor) Client(org.apache.cxf.endpoint.Client) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL) TransformInInterceptor(org.apache.cxf.interceptor.transform.TransformInInterceptor) Test(org.junit.Test)

Aggregations

URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 BookSoapService (org.apache.cxf.systest.jaxrs.jaxws.BookSoapService)2 BookStoreJaxrsJaxws (org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Client (org.apache.cxf.endpoint.Client)1 TransformInInterceptor (org.apache.cxf.interceptor.transform.TransformInInterceptor)1 TransformOutInterceptor (org.apache.cxf.interceptor.transform.TransformOutInterceptor)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1