Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Consume Webservice in java

Thread view: 
weetat - 04 Apr 2007 04:30 GMT
Hi all , I need to call method from webservice that I have created.
The webservice is deployed in jboss 4.0.4 and the webservice is simple
Hello test.

However , when i tried to call method , it gave error below:

I am new in webservice . Anyone have any ideas or suggestion is much
appreciated. Thanks

serialization error: serialization error:
java.lang.NullPointerException
       at
com.sun.xml.rpc.encoding.DynamicInternalTypeMappingRegistry.getSerializer(DynamicInternalTypeMappingRegistry.java:
196)
       at
com.sun.xml.rpc.encoding.literal.LiteralResponseSerializer.initialize(LiteralResponseSerializer.java:
230)
       at
com.sun.xml.rpc.client.dii.BasicCall.createRpcLiteralResponseSerializer(BasicCall.java:
757)
       at
com.sun.xml.rpc.client.dii.BasicCall.getResponseDeserializer(BasicCall.java:
690)
       at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:
486)
       at com.test.client.TestWebService.main(TestWebService.java:45)

This is the web service client code:

public static void main(String [] args){

       try{

        String wsdlURL = "http://cxrus020:8080/HelloWebService/
HelloWS?wsdl";
        String namespace = "urn:HelloWS/wsdl";
        String serviceName = "HelloWS";
        QName serviceQN = new QName(namespace, serviceName);

        ServiceFactory serviceFactory = ServiceFactory.newInstance();
        Service service = serviceFactory.createService(new
URL(wsdlURL), serviceQN);
        Call call = service.createCall();
        call.setPortTypeName(serviceQN);
        call.setOperationName(new QName(namespace, "greet"));
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");


call.addParameter("string_1",serviceQN,javax.xml.rpc.ParameterMode.IN);
        call.setReturnType(serviceQN);
        Object[] inParams = new Object[]{"weetat is testing"};
        String ret = (String) call.invoke(inParams);
        System.out.println("ret:" + ret);

       }catch(Exception ex){
           ex.printStackTrace();
       }

The wsdl file for your reference :

<definitions name='HelloWS' targetNamespace='urn:HelloWS/wsdl'
xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://
schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='urn:HelloWS/wsdl'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types></types>
<message name='HelloWSSEI_greet'>
 <part name='String_1' type='xsd:string'/>
</message>
<message name='HelloWSSEI_greetResponse'>
 <part name='result' type='xsd:string'/>
</message>
<portType name='HelloWSSEI'>
 <operation name='greet' parameterOrder='String_1'>
  <input message='tns:HelloWSSEI_greet'/>
  <output message='tns:HelloWSSEI_greetResponse'/>
 </operation>
</portType>
<binding name='HelloWSSEIBinding' type='tns:HelloWSSEI'>
 <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/
http'/>
 <operation name='greet'>
  <soap:operation soapAction=''/>
  <input>
   <soap:body namespace='urn:HelloWS/wsdl' use='literal'/>
  </input>
  <output>
   <soap:body namespace='urn:HelloWS/wsdl' use='literal'/>
  </output>
 </operation>
</binding>
<service name='HelloWS'>
 <port binding='tns:HelloWSSEIBinding' name='HelloWSSEIPort'>
  <soap:address location='http://cxrus020:8080/HelloWebService/
HelloWS'/>
 </port>
</service>
</definitions>
Brandon McCombs - 04 Apr 2007 05:36 GMT
> Hi all , I need to call method from webservice that I have created.
> The webservice is deployed in jboss 4.0.4 and the webservice is simple
[quoted text clipped - 25 lines]
> This is the web service client code:
> [snip]

Based on the error it doesn't have anything to do with web services
specifically. This is a basic null pointer exception that can occur
anywhere in Java.  What are you doing on line 196 in the
DynamicInternalTypeMappingRegistry.java class?  That's where the null
pointer is being referenced. If that isn't your class (since it's in a
package from sun) then you need to trace the source of the null pointer
into one of your classes.....such as line 45 in TestWebService.java.
Mike Schilling - 04 Apr 2007 07:42 GMT
> Hi all , I need to call method from webservice that I have created.
> The webservice is deployed in jboss 4.0.4 and the webservice is simple
[quoted text clipped - 4 lines]
> I am new in webservice . Anyone have any ideas or suggestion is much
> appreciated. Thanks

A few things stand out:

1. The error appears to come while deserializing the response.
2. The following line looks odd to me:

   call.setReturnType(serviceQN);

since serviceQN is neither a type nor the name of a type
3. The NPE appears to come while looking up a type in a registry of types.

Perhaps you want to call setReturnType(new
QName("'http://www.w3.org/2001/XMLSchema", "string"));
weetat - 04 Apr 2007 08:04 GMT
Hi,

 Added , similar problem.
 Please explain again , I am deploying a simple Hello Web service to
jboss-4.0.4-GA server with bundled in the Netbean 5.5 IDE.

 Deployment of webservice in the JBoss is ok , when i do
http://localhost:8080/HelloWebService/HelloWS?wsdl , i can see the
wsdl format.
 And when accessing the webservice using Web Service Client in
Netbean , i can access the web service method without any error.

 My problem is the when i tried to access the web service in normal
java class for example below:
 Anyone have any ideas or suggestion , please email it to me , thanx

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

public class TestWebService {

   /** Creates a new instance of TestWebService */
   public static void main(String [] args){

    try{

        String wsdlURL = "http://cxrus020:8080/HelloWebService/
HelloWS?wsdl";
        String namespace = "urn:HelloWS/wsdl";
        String serviceName = "HelloWS";
        QName serviceQN = new QName(namespace, serviceName);

        ServiceFactory serviceFactory = ServiceFactory.newInstance();
        Service service = serviceFactory.createService(new
URL(wsdlURL), serviceQN);
        QName portQname = new QName(namespace, "HelloWSSEIPort");

        Call call = service.createCall(portQname);
        call.setPortTypeName(portQname);
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
        QName requestQname = new QName(namespace, "greet");
        call.addParameter("String_1", requestQname,
javax.xml.rpc.ParameterMode.IN);
        call.setReturnType(requestQname);
        String ret = (String) call.invoke(new Object[]{"joshua
tat"});
        System.out.println("ret:" + ret);

       }catch(Exception ex){
           ex.printStackTrace();
       }

}

On Apr 4, 2:42 pm, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
> > Hi all , I need to call method from webservice that I have created.
> > The webservice is deployed in jboss 4.0.4 and the webservice is simple
[quoted text clipped - 17 lines]
> Perhaps you want to call setReturnType(new
> QName("'http://www.w3.org/2001/XMLSchema", "string"));


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.