Problem running webservice client created using JWSDP 1.6
fsilva_vormetric May 4, 2006 5:09 PMI am currently using :
JBOSS AS 4.0.3sp1
JWSDP 1.6
I dowloaded JWSDP 1.6 and ran the ant build scripts in the the JWSDPHOME/jaxrpc/samples/HelloWorld directory:
This produced a jaxrpc-HelloWorld.war. I copied this war file to JBOSSHOME/server/mytestserver/deploy directory:
Initially, JBOSS was not able to deploy my war file because of missing classes. So I copied the following JWSDP 1.6 jar files to the JBOSSHOME/server/mytestserver/deploy/lib directory:
jaxrpc-impl.jar
jaxrpc-spi.jar
saaj-impl.jar
FastInfoSet.jar
I started the JBOSS AS and it successfully deployed my HelloWorldService. But I have a problem with my webservice client. Here is the code for the client (which came with the JWSDP 1.6 samples):
package hello;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import com.sun.xml.rpc.client.StubPropertyConstants;
import com.sun.xml.rpc.client.dii.CallPropertyConstants;
/**
* This sample demonstrates how to enable content negotiation
* for Fast Infoset. By default, content negotiation is turned
* off but can be enabled by setting a property on a Stub or
* Call. Once Fast Infoset is negotiated, any subsequent
* exchange between the client and the service will be in
* "optimistic" mode (i.e., both the request and reply will
* be encoded using Fast Infoset).
*
* @author Santiago.PericasGeertsen@sun.com
*/
public class HelloClient {
HelloIF_Stub stub;
HelloWorldService helloWorldService;
Call call;
public static void main(String[] args) {
try {
// Set endpoint URL
System.setProperty(
"endpoint",
"http://localhost:8080/jaxrpc-HelloWorld/hello");
HelloClient hc = new HelloClient();
hc.setUp();
hc.testStubInitialState();
hc.testPessimisticContentNegotiation();
hc.testCallInitialState();
hc.testPessimisticContentNegotiationDII();
}
catch (Exception e) {
e.printStackTrace();
}
}
protected void setUp() {
try {
helloWorldService = new HelloWorldService_Impl();
stub = (HelloIF_Stub) (helloWorldService.getHelloIFPort());
stub._setProperty(
javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
System.getProperty("endpoint"));
// Create a DII call to invoke sayHelloBack
call = helloWorldService.createCall(
new QName("http://hello.org/wsdl", "HelloIFPort"),
new QName("http://hello.org/wsdl", "sayHelloBack"));
call.setTargetEndpointAddress(System.getProperty("endpoint"));
call.setProperty(
"javax.xml.rpc.soap.operation.style",
"rpc");
call.setProperty(
"javax.xml.rpc.encodingstyle.namespace.uri",
"http://schemas.xmlsoap.org/soap/encoding/");
call.addParameter(
"String_1",
new QName("http://www.w3.org/2001/XMLSchema", "string"),
ParameterMode.IN);
call.setReturnType(
new QName("http://www.w3.org/2001/XMLSchema", "string"));
}
catch (Exception e) {
e.printStackTrace();
}
}
void testStubInitialState() {
assertTrue(getContentNegotiation() == "none");
}
void testPessimisticContentNegotiation() {
// Set initial state
setContentNegotiation("pessimistic");
// Precondition
assertTrue(getContentNegotiation() == "pessimistic");
// XML request - FI reply
try {
System.out.println(stub.sayHelloBack("JAXRPC Sample"));
}
catch (Exception ex) {
ex.printStackTrace();
}
// Postcondition - FI is negotiated
assertTrue(getContentNegotiation() == "optimistic");
}
// DII
void testCallInitialState() {
assertTrue(getContentNegotiationDII() == "none");
}
void testPessimisticContentNegotiationDII() {
// Set initial state
setContentNegotiationDII("pessimistic");
// Precondition
assertTrue(getContentNegotiationDII() == "pessimistic");
// XML request - FI reply
try {
Object[] in = new Object[] { "JAXRPC Sample" };
System.out.println((String) call.invoke(in));
}
catch (Exception ex) {
ex.printStackTrace();
}
// Postcondition - FI is negotiated
assertTrue(getContentNegotiationDII() == "optimistic");
}
// --- Utility Methods -----------------------------------------------
private void setContentNegotiation(String value) {
stub._setProperty(StubPropertyConstants.CONTENT_NEGOTIATION_PROPERTY,
value);
}
private String getContentNegotiation() {
return (String) stub._getProperty(StubPropertyConstants.CONTENT_NEGOTIATION_PROPERTY);
}
// DII
private void setContentNegotiationDII(String value) {
call.setProperty(CallPropertyConstants.CONTENT_NEGOTIATION_PROPERTY,
value);
}
private String getContentNegotiationDII() {
return (String) call.getProperty(CallPropertyConstants.CONTENT_NEGOTIATION_PROPERTY);
}
private void assertTrue(boolean value) {
if (!value) throw new RuntimeException("Assertion failed.");
}
}
Please note that I compiled and ran this client using the build script that came with the JWSDP 1.6. The build script classpath only points to jar files that came with the JWSDP, the classpath does not point to any JBoss jar files.
I get this error from the JBOSS AS:
SEVERE: JAXRPCTIE01: caught exception while handling request: java.lang.ClassCastException: org.jboss.axis.soap.MessageFactoryImpl
java.lang.ClassCastException: org.jboss.axis.soap.MessageFactoryImpl
at com.sun.xml.rpc.soap.message.SOAPMessageContext.createMessage(SOAPMessageContext.java:134)
at com.sun.xml.rpc.server.StreamingHandlerState.getResponse(StreamingHandlerState.java:57)
at com.sun.xml.rpc.server.StreamingHandler.writeResponse(StreamingHandler.java:702)
at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:418)
at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:448)
at com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(JAXRPCServlet.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
2006-05-04 12:10:46,111 INFO [STDOUT] May 4, 2006 12:10:46 PM com.sun.xml.rpc.server.StreamingHandler handle
SEVERE: JAXRPCTIE02: caught exception while preparing response: java.lang.ClassCastException: org.jboss.axis.soap.MessageFactoryImpl
java.lang.ClassCastException: org.jboss.axis.soap.MessageFactoryImpl
at com.sun.xml.rpc.soap.message.SOAPMessageContext.createMessage(SOAPMessageContext.java:134)
at com.sun.xml.rpc.server.StreamingHandlerState.getResponse(StreamingHandlerState.java:57)
at com.sun.xml.rpc.server.StreamingHandlerState.resetResponse(StreamingHandlerState.java:70)
at com.sun.xml.rpc.server.StreamingHandler.reportFault(StreamingHandler.java:1031)
at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:449)
at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:448)
at com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(JAXRPCServlet.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
2006-05-04 12:10:46,158 INFO [STDOUT] May 4, 2006 12:10:46 PM com.sun.xml.rpc.server.http.JAXRPCServletDelegate doPost
SEVERE: caught throwable
.....
Perhaps the steps that I followed to compile and deploy are wrong. Can someone please point me to the reason for the error? thanks.