-
How to create Web Service Client
Hi I m trying to create the jaxrpc client to access my web service deployed on jboss-4.0.4.GA. But I m unable to access it and got the following exception :
log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.JSR109ClientMetaDataBuilder).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://poc.qc/jaws}greet
at org.jboss.ws.metadata.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilde r.java:442)
at org.jboss.ws.metadata.JSR109MetaDataBuilder.setupOperationsFromWSDL(JSR109MetaDataBuilder. java:193)
at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaDataInternal(JSR109ClientMetaDa taBuilder.java:207)
at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilde r.java:122)
at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilde r.java:78)
at org.jboss.ws.jaxrpc.ServiceImpl.<init>(ServiceImpl.java:96)
at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128)
at com.qc.client.Client.main(Client.java:32)
My service contains a single method named greet that takes a string parameter and returns a string . the wsdl file that is generated is as follows :
- <definitions name="HelloService" targetNamespace="http://poc.qc/jaws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://poc.qc/jaws" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <types>
- <schema elementFormDefault="qualified" targetNamespace="http://poc.qc/jaws" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://poc.qc/jaws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <complexType name="greet">
- <sequence>
<element name="name" nillable="true" type="string" />
</sequence>
</complexType>
- <complexType name="greetResponse">
- <sequence>
<element name="result" nillable="true" type="string" />
</sequence>
</complexType>
<element name="greet" type="tns:greet" />
<element name="greetResponse" type="tns:greetResponse" />
</schema>
</types>
- <message name="Hello_greet">
<part element="tns:greet" name="parameters" />
</message>
- <message name="Hello_greetResponse">
<part element="tns:greetResponse" name="result" />
</message>
- <portType name="Hello">
- <operation name="greet">
<input message="tns:Hello_greet" />
<output message="tns:Hello_greetResponse" />
</operation>
</portType>
- <binding name="HelloBinding" type="tns:Hello">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="greet">
<soap peration soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="HelloService">
- <port binding="tns:HelloBinding" name="HelloPort">
<soap:address location="http://wks171:8080/POCWS2/Hello" />
</port>
</service>
</definitions>
And my client code is as follows :
package com.qc.client;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Call;
import javax.xml.namespace.QName;
import java.net.URL;
public class Client
{
public static void main(String[] args)
throws Exception
{
String urlstr = "http://10.1.1.171:8080/POCWS2/Hello?wsdl";
String argument = "Friend" ;
System.out.println("Contacting webservice at " + urlstr);
URL url = new URL(urlstr);
String ns = "http://poc.qc/jaws";
QName qname = new QName(ns, "HelloService");
QName port = new QName(ns, "HelloPort");
QName operation = new QName(ns, "greet");
System.out.println("ns-->" +ns );
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(url, qname);
Call call = service.createCall(port, operation);
System.out.println("hello.hello(" + argument + ")");
System.out.println("output:" + call.invoke(new Object[] {argument}));
}
}
Please help me out that how can I access my web service ?
Similar Threads
-
By jyoungday in forum Java
Replies: 0
Last Post: 03-23-2006, 12:51 AM
-
Replies: 0
Last Post: 06-15-2005, 04:50 AM
-
Replies: 0
Last Post: 09-25-2002, 07:46 AM
-
By Robert Lantry in forum .NET
Replies: 278
Last Post: 03-27-2002, 01:00 PM
-
By Tim Romano in forum .NET
Replies: 0
Last Post: 04-19-2001, 07:54 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks