[JBossWS] - Re: Writing a client - no examples for BindingProvider based
by alessio.soldano@jboss.com
"mjhammel" wrote :
| Then I discovered that the source was actually JBOSS-WS from http://labs.jboss.com/jbossws/downloads/. My first questions, then, are this: isn't WS included in the application server? Do I need to download the WS binary and add it to the JBOSS application server (for V4.2.2GA of the app server)?
|
The application server includes a webservice stack (JBossWS) you can of course use without any further installation. However you would probably want to upgrade the ws stack since JBossWS is released more often than the application server.
anonymous wrote :
| Looking through the examples in the WS source code I cannot find an example that seems to implement the simplistic code shown in the client example here:
| http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools#Cli...
|
Most of the examples use an equivalent generic way of getting the endpoint that is
| Service service = Service.create(wsdlURL, qname);
| MyEndpoint port = (MyEndpoint)service.getPort(MyEndpoint.class);
|
however you can take a look at the org.jboss.test.ws.jaxws.samples.retail sample which also has a @WebServiceClient annotated service class generated through the tools.
anonymous wrote :
| I was hoping it would be as easy as this shows, with the added properties to the BindingProvider for username and password.
|
And it should be that easy. Take a look at the org.jboss.test.ws.jaxws.samples.context sample, it is a real simple test case and uses basic auth.
anonymous wrote :
| I've written this client, but it fails to compile with an error I've not seen in any discussions or in any googled pages:
|
| package wsTestJAXWS;
| |
| | import java.net.URL;
| | import javax.xml.ws.*;
| | import javax.jws.*;
| |
| | /* Web Services interfaces */
| | import com.cei.crunch.server.subscriberservices.*;
| |
| | /* Crunch DB tables. */
| | import com.cei.crunch.ejb.Subscriber;
| |
| | public class wsTestJAXWS {
| |
| | private static URL targetURL = null;
| | private String subscriberID = null;
| | private String pw = null;
| | private String host = null;
| | private String crunchServer = null;
| | private Subscriber profile = null;
| | SubscriberServicesEndpoint ss = null;
| |
| | private boolean serviceBind()
| | {
| | try {
| |
| | SubscriberServicesService service = new SubscriberServicesService();
| | ss = service.getSubscriberServicesPort();
| |
| | /* Set NEW Endpoint Location */
| | BindingProvider bp = (BindingProvider)ss;
| | bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, crunchServer);
| |
| | /* Setup to authenticate with the server. */
| | bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, subscriberID);
| | bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pw);
| |
| | return true;
| | }
| | catch (Exception e) {
| | System.out.println("Failed to login to server.");
| | System.exit(1);
| | }
| | return false;
| | }
| |
| | public void run(String[] args) {
| |
| | /* Save the subscriber login information. */
| | if ( args.length != 3 )
| | {
| | System.out.println("Missing command line args (userid, password, server).");
| | System.exit(1);
| | }
| | this.subscriberID = args[0];
| | this.pw = args[1];
| | this.host = args[2];
| |
| | // crunchServer = "https://" + this.host + ":8443/Crunch/services/SubscriberServices";
| | crunchServer = "http://" + this.host + ":8080/Crunch/services/SubscriberServices";
| | System.out.println("Trying to connect to " + crunchServer + " as User: " + subscriberID + ", password: " + pw);
| |
| | /* Get the WSDL interfaces to the server. */
| | if ( serviceBind() == false )
| | {
| | System.out.println("Login failed.");
| | System.exit(1);
| | }
| |
| | /* Retrieve subscriber profile information. */
| | try {
| | profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
| | }
| | catch (Exception e) {
| | System.out.println("Failed findSubscriber(): " + e.getMessage());
| | e.printStackTrace();
| | System.exit(1);
| | }
| | if ( profile == null )
| | {
| | System.out.println("findSubscriber() failed.");
| | System.exit(1);
| | }
| |
| | System.out.println("Subscriber name : " + profile.getFirstname());
| | System.out.println("Subscriber email: " + profile.getEmailAddress());
| | }
| |
| | public static void main(String[] args) {
| | new wsTestJAXWS().run(args);
| | }
| |
| | }
|
| The compile time error is this:
|
| -client.test:
| | [javac] Compiling 1 source file to /home/mjhammel/src/cei/crunch/build/classes/client
| | [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:74: cannot access javax.xml.bind.annotation.XmlAccessorType
| | [javac] file javax/xml/bind/annotation/XmlAccessorType.class not found
| | [javac] profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
| | [javac] ^
| | [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:76: cannot access javax.xml.bind.annotation.XmlElement
| | [javac] file javax/xml/bind/annotation/XmlElement.class not found
| | [javac] catch (Exception e) {
| | [javac] ^
| | [javac] 2 errors
|
| I can't find any discussion on what the XmlAccessorType or XmlElement classes are or why they're being referenced at the specified points in my code.
|
| FYI: The SubscriberServicesService class is being generated using wsconsume (http://jbws.dyndns.org/mediawiki/index.php?title=Wsconsume).
|
This seems to me an issue with the libraries in your classpath. Check for example that jaxb-api.jar is in your classpath.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116938#4116938
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116938
16 years, 11 months
(no subject)
by Rajagopal_Yendluri
Hi,
I am new to JBoss WS, I just started working on this for a POC, I
successfully installed the WS on JBoss AS.
When I try to run the samples, by using...ant from jbossWS home, am
getting the following exceptions...
I can understand that the junit.jar is missing and something for
assertions, but let me know where can I keep the junit.jar... it exists
in lib directory of JBossWS.
Any Suggestions....
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\xop\doclit\XOPHandlerTestCase.
java:58: cannot find symbol
[javac] symbol : class Test
[javac] location: class
org.jboss.test.ws.jaxws.samples.xop.doclit.XOPHandlerTestCase
[javac] public static Test suite()
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\xop\doclit\XOPWrappedTestCase.
java:53: cannot find symbol
[javac] symbol : class Test
[javac] location: class
org.jboss.test.ws.jaxws.samples.xop.doclit.XOPWrappedTestCase
[javac] public static Test suite()
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\smoke\tools\ScriptTestCase.java:37:
cannot find symbol
[javac] symbol: class TestCase
[javac] public class ScriptTestCase extends TestCase
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\smoke\tools\WSConsumerTestCase.java:46
: cannot find symbol
[javac] symbol: class TestCase
[javac] public class WSConsumerTestCase extends TestCase
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\serviceref\EJBClient.java:38:
cannot find symbol
[javac] symbol: class RemoteBinding
[javac] @RemoteBinding(jndiBinding = "/ejb/EJBClient")
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\webserviceref\EJB3Client.java:
38: cannot find symbol
[javac] symbol: class RemoteBinding
[javac] @RemoteBinding(jndiBinding = "/ejb3/EJB3Client")
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\asynchronous\AsynchronousDispa
tchTestCase.java:66: cannot access junit.extensions.TestSetup
[javac] file junit\extensions\TestSetup.class not found
[javac] return new
JBossWSTestSetup(AsynchronousDispatchTestCase.class,
"jaxws-samples-asynchronous.war");
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\asynchronous\AsynchronousDispa
tchTestCase.java:100: cannot find symbol
[javac] symbol : method assertTrue(java.lang.String,boolean)
[javac] location: class
org.jboss.test.ws.jaxws.samples.asynchronous.AsynchronousDispatchTestCas
e
[javac] assertTrue("Async handler called", asyncHandlerCalled);
[javac] ^
[javac]
C:\Rajagopal\Softwares\jbossws-native-2.0.2.GA\jbossws-native-2.0.2.GA\t
ests\java\org\jboss\test\ws\jaxws\samples\asynchronous\AsynchronousDispa
tchTestCase.java:105: cannot find symbol
Regards,
Rajagopal Y (Raj)
HCU-Consulting & Enterprise Solutions.
Phone: (C) +91-9986584084 / (W)+91-80-6658 3685.
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.
16 years, 11 months
[JBossWS] - Writing a client - no examples for BindingProvider based doc
by mjhammel
Short background: I'm migrating a project from JBOSS 4.0.5GA that used Axis to generate WSDL interfaces for my JAX-RPC based clients.
I've got a simple web service up under JBOSS. I can see it under http://localhost:8080/jbossws/services. It has a very simplistic Web Service that simply reads data from a table in the DB using EJB's generated using Hibernate to reveng an existing db. Accessing the WSDL through the localhost url requires a login userid and password, which seems to mean I have my database-based authentication setup correctly (or at least I think it does). The server side appears ready to access with a client.
So I've read up on writing clients:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=62678 (found the Wiki pages and sample explanations discussed there:
http://jbws.dyndns.org/mediawiki/index.php?title=Samples)
http://jbws.dyndns.org/mediawiki/index.php?title=JAX-WS_User_Guide#Servic...
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=123643
http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools#Cli...
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=108760
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=104091
http://jbws.dyndns.org/mediawiki/index.php?title=Authentication
http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools
All the examples I can find show the use of BindingProvider to set the username and password. Some of these links suggest looking at the example code in the testsuite in the JBOSS source code. So I downloaded the JBOSS-4.2.2GA source but none of the code (any of it) uses BindingProvider.
Then I discovered that the source was actually JBOSS-WS from http://labs.jboss.com/jbossws/downloads/. My first questions, then, are this: isn't WS included in the application server? Do I need to download the WS binary and add it to the JBOSS application server (for V4.2.2GA of the app server)? At the moment I've got a compile-time problem so have not been able to simply try it and find out.
Looking through the examples in the WS source code I cannot find an example that seems to implement the simplistic code shown in the client example here:
http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools#Cli...
I was hoping it would be as easy as this shows, with the added properties to the BindingProvider for username and password. The SimpleUserNameTestCase example uses a QName class and does a Service.create(), something the JAX-WS Tools page (http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools#Cli...) recommends not doing.
I've written this client, but it fails to compile with an error I've not seen in any discussions or in any googled pages:
package wsTestJAXWS;
|
| import java.net.URL;
| import javax.xml.ws.*;
| import javax.jws.*;
|
| /* Web Services interfaces */
| import com.cei.crunch.server.subscriberservices.*;
|
| /* Crunch DB tables. */
| import com.cei.crunch.ejb.Subscriber;
|
| public class wsTestJAXWS {
|
| private static URL targetURL = null;
| private String subscriberID = null;
| private String pw = null;
| private String host = null;
| private String crunchServer = null;
| private Subscriber profile = null;
| SubscriberServicesEndpoint ss = null;
|
| private boolean serviceBind()
| {
| try {
|
| SubscriberServicesService service = new SubscriberServicesService();
| ss = service.getSubscriberServicesPort();
|
| /* Set NEW Endpoint Location */
| BindingProvider bp = (BindingProvider)ss;
| bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, crunchServer);
|
| /* Setup to authenticate with the server. */
| bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, subscriberID);
| bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pw);
|
| return true;
| }
| catch (Exception e) {
| System.out.println("Failed to login to server.");
| System.exit(1);
| }
| return false;
| }
|
| public void run(String[] args) {
|
| /* Save the subscriber login information. */
| if ( args.length != 3 )
| {
| System.out.println("Missing command line args (userid, password, server).");
| System.exit(1);
| }
| this.subscriberID = args[0];
| this.pw = args[1];
| this.host = args[2];
|
| // crunchServer = "https://" + this.host + ":8443/Crunch/services/SubscriberServices";
| crunchServer = "http://" + this.host + ":8080/Crunch/services/SubscriberServices";
| System.out.println("Trying to connect to " + crunchServer + " as User: " + subscriberID + ", password: " + pw);
|
| /* Get the WSDL interfaces to the server. */
| if ( serviceBind() == false )
| {
| System.out.println("Login failed.");
| System.exit(1);
| }
|
| /* Retrieve subscriber profile information. */
| try {
| profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
| }
| catch (Exception e) {
| System.out.println("Failed findSubscriber(): " + e.getMessage());
| e.printStackTrace();
| System.exit(1);
| }
| if ( profile == null )
| {
| System.out.println("findSubscriber() failed.");
| System.exit(1);
| }
|
| System.out.println("Subscriber name : " + profile.getFirstname());
| System.out.println("Subscriber email: " + profile.getEmailAddress());
| }
|
| public static void main(String[] args) {
| new wsTestJAXWS().run(args);
| }
|
| }
The compile time error is this:
-client.test:
| [javac] Compiling 1 source file to /home/mjhammel/src/cei/crunch/build/classes/client
| [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:74: cannot access javax.xml.bind.annotation.XmlAccessorType
| [javac] file javax/xml/bind/annotation/XmlAccessorType.class not found
| [javac] profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
| [javac] ^
| [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:76: cannot access javax.xml.bind.annotation.XmlElement
| [javac] file javax/xml/bind/annotation/XmlElement.class not found
| [javac] catch (Exception e) {
| [javac] ^
| [javac] 2 errors
I can't find any discussion on what the XmlAccessorType or XmlElement classes are or why they're being referenced at the specified points in my code.
FYI: The SubscriberServicesService class is being generated using wsconsume (http://jbws.dyndns.org/mediawiki/index.php?title=Wsconsume).
Any pointers to getting this first test client working with username/password login (BASIC authentication, with DatabaseServerLoginModule configured in my application-policy) would be greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116866#4116866
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116866
16 years, 11 months