11package org .javaee7 .jaxrpc .endpoint ;
22
3+ import static javax .xml .rpc .Call .SOAPACTION_URI_PROPERTY ;
4+ import static javax .xml .rpc .Call .SOAPACTION_USE_PROPERTY ;
5+ import static javax .xml .rpc .ParameterMode .IN ;
36import static org .jboss .shrinkwrap .api .ShrinkWrap .create ;
7+ import static org .junit .Assert .assertEquals ;
48
59import java .io .File ;
6-
7- //import static org.junit.Assert.assertEquals;
8-
910import java .net .MalformedURLException ;
1011import java .net .URL ;
12+ import java .rmi .RemoteException ;
13+
14+ import javax .xml .namespace .QName ;
15+ import javax .xml .rpc .Call ;
16+ import javax .xml .rpc .ServiceException ;
17+ import javax .xml .rpc .ServiceFactory ;
1118
1219import org .jboss .arquillian .container .test .api .Deployment ;
20+ import org .jboss .arquillian .container .test .api .RunAsClient ;
1321import org .jboss .arquillian .junit .Arquillian ;
1422import org .jboss .arquillian .test .api .ArquillianResource ;
1523import org .jboss .shrinkwrap .api .spec .WebArchive ;
16- import org .junit .Before ;
1724import org .junit .Test ;
1825import org .junit .runner .RunWith ;
1926
2027@ RunWith (Arquillian .class )
2128public class HelloTest {
2229
2330 private static final String WEBAPP_SRC = "src/main/webapp" ;
31+ private static final String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri" ;
32+ private static final String NS_XSD = "http://www.w3.org/2001/XMLSchema" ;
2433
2534 @ ArquillianResource
2635 private URL url ;
2736
37+
2838 @ Deployment (testable = false )
2939 public static WebArchive createDeployment () {
30- System .out .println ("************************ ************************************" );
40+ System .out .println ("************** DEPLOYING ************************************" );
3141
3242 WebArchive war =
3343 create (WebArchive .class )
@@ -44,13 +54,46 @@ public static WebArchive createDeployment() {
4454 return war ;
4555 }
4656
47- @ Before
48- public void setupClass () throws MalformedURLException {
57+ @ Test
58+ @ RunAsClient
59+ public void testHelloProxy () throws MalformedURLException , ServiceException , RemoteException {
60+ HelloService helloService = (HelloService )
61+ ServiceFactory .newInstance ()
62+ .createService (
63+ new URL (url , "hello?wsdl" ),
64+ new QName ("urn:sample" , "MyHelloService" ))
65+ .getPort (
66+ new QName ("urn:sample" , "HelloServicePort" ),
67+ HelloService .class );
68+
69+ String result = helloService .sayHello ("Sailor" );
70+
71+ assertEquals ("Hello Sailor" , result );
4972 }
5073
5174 @ Test
52- public void testHello () throws MalformedURLException {
75+ @ RunAsClient
76+ public void testHelloDII () throws MalformedURLException , ServiceException , RemoteException {
77+ Call call = ServiceFactory .newInstance ()
78+ .createService (new QName ("MyHelloService" ))
79+ .createCall (new QName ("HelloServicePort" ));
80+
81+ call .setTargetEndpointAddress (url + "hello" );
82+
83+ call .setProperty (SOAPACTION_USE_PROPERTY , true );
84+ call .setProperty (SOAPACTION_URI_PROPERTY , "" );
85+ call .setProperty (ENCODING_STYLE_PROPERTY , "http://schemas.xmlsoap.org/soap/encoding/" );
86+
87+ call .setReturnType (new QName (NS_XSD , "string" ));
88+ call .setOperationName (new QName ("urn:sample" , "sayHello" ));
89+ call .addParameter ("String_1" , new QName (NS_XSD , "string" ), IN );
90+
91+ String result = (String ) call .invoke (new String [] { "Captain" });
92+
93+ assertEquals ("Hello Captain" , result );
5394 }
5495
5596
97+
98+
5699}
0 commit comments