You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-user@ws.apache.org by rizwan patel <ri...@gmail.com> on 2008/01/26 18:24:17 UTC

[WSIFException]:invoking service method

Please help me out. I have to invoke the web services dynamically. I gone
thru the WSIF concepts and it will be helpful for me to invoke the services
with this framework. I had written  webservice "HelloWorld" and also
generated the client code for that in WSIF but i am not succeded in invoking
the webservice.
Please help me to come out of this problem it is on urgent priority as i
have to give the presentation on dynamic invocation.
Your help is very worth valuable for me.The detail is as below.
I am sending you the complete details such as WSDL, Client code ,Output, and
also the web-service method server side.
I had deploy the HelloWorld.aar file into jakarta-tomcat-5.
The location of service is  :
http://<localhost>:8080/axis2/services/listServices
Service code :
*HelloInterface.java*

package hello;
public interface HelloInterface
{
 public int sayHello(java.lang.String str_1);
}

*HelloWorld.java*

package hello;

public class HelloWorld implements HelloInterface, java.rmi.Remote
{
 public int sayHello(java.lang.String str_1)
 {
  System.out.println("Welcome in HelloWorld :"+str_1);
  return 10;
 }

}

*Service.xml :*

<service name="HelloWorld" scope="application" targetNamespace="http://hello
">
    <description>
        Say Hello
    </description>
    <messageReceivers>
       <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
            class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <schema schemaNamespace="http://hello/xsd"/ <http://hello/xsd%22/>>
    <parameter name="ServiceClass">hello.HelloWorld</parameter>
</service>

*build.xml*

<project basedir="." default="generate.service">

    <property environment="env"/>
    <property name="AXIS2_HOME" value="${env.AXIS2_HOME}"/>

    <property name="build.dir" value="build"/>

    <path id="axis2.classpath">
        <fileset dir="${AXIS2_HOME}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="compile.service">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${build.dir}/classes"/>

        <!--First let's compile the classes-->
        <javac debug="on"
               fork="true"
               destdir="${build.dir}/classes"
               srcdir="${basedir}/src"
               classpathref="axis2.classpath">
        </javac>
    </target>

    <target name="generate.wsdl" depends="compile.service">
        <taskdef name="java2wsdl"
                 classname="org.apache.ws.java2wsdl.Java2WSDLTask"
                 classpathref="axis2.classpath"/>
        <java2wsdl className="hello.HelloWorld"
                   outputLocation="${build.dir}"
                   targetNamespace="http://hello"
                   schemaTargetNamespace="http://hello/xsd">
            <classpath>
                <pathelement path="${axis2.classpath}"/>
                <pathelement location="${build.dir}/classes"/>
            </classpath>
        </java2wsdl>
    </target>

    <target name="generate.service" depends="compile.service">
        <!--aar them up -->
        <copy toDir="${build.dir}/classes" failonerror="false">
            <fileset dir="${basedir}/resources">
                <include name="**/*.xml"/>
            </fileset>
        </copy>
        <jar destfile="${build.dir}/HelloWorld.aar">
            <fileset excludes="**/Test.class" dir="${build.dir}/classes"/>
        </jar>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>
</project>

*HelloWorld.wsdl*

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:axis2="http://hello" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns0="http://hello/xsd" xmlns:soap12="
http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="
http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="
http://org.apache.axis2/xsd" xmlns:wsaw="
http://www.w3.org/2006/05/addressing/wsdl" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://hello">
    <wsdl:types>
        <xs:schema xmlns:xsd="http://hello/xsd" targetNamespace="
http://hello/xsd" attributeFormDefault="qualified"
elementFormDefault="qualified">
            <xs:element name="sayHello">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="str_1" minOccurs="0"
type="xs:string" nillable="true"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="sayHelloResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="return" minOccurs="0"
type="xs:int"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="sayHelloRequest">
        <wsdl:part name="parameters" element="ns0:sayHello"/>
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
        <wsdl:part name="parameters" element="ns0:sayHelloResponse"/>
    </wsdl:message>
    <wsdl:portType name="HelloWorldPortType">
        <wsdl:operation name="sayHello">
            <wsdl:input message="axis2:sayHelloRequest"
wsaw:Action="urn:sayHello"/>
            <wsdl:output message="axis2:sayHelloResponse"
wsaw:Action="urn:sayHelloResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloWorldSOAP11Binding"
type="axis2:HelloWorldPortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
        <wsdl:operation name="sayHello">
            <soap:operation soapAction="urn:sayHello" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="HelloWorldSOAP12Binding"
type="axis2:HelloWorldPortType">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
        <wsdl:operation name="sayHello">
            <soap12:operation soapAction="urn:sayHello" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="HelloWorldHttpBinding"
type="axis2:HelloWorldPortType">
        <http:binding verb="POST"/>
        <wsdl:operation name="sayHello">
            <http:operation location="HelloWorld/sayHello"/>
            <wsdl:input>
                <mime:content type="text/xml" part="sayHello"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="sayHello"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloWorld">
        <wsdl:port name="HelloWorldSOAP11port_http"
binding="axis2:HelloWorldSOAP11Binding">
            <soap:address location="
http://localhost:8080/axis2/services/HelloWorld"/<http://localhost:8080/axis2/services/HelloWorld%22/>
>
        </wsdl:port>
        <wsdl:port name="HelloWorldSOAP12port_http"
binding="axis2:HelloWorldSOAP12Binding">
            <soap12:address location="
http://localhost:8080/axis2/services/HelloWorld"/<http://localhost:8080/axis2/services/HelloWorld%22/>
>
        </wsdl:port>
        <wsdl:port name="HelloWorldHttpport"
binding="axis2:HelloWorldHttpBinding">
            <http:address location="
http://localhost:8080/axis2/services/HelloWorld"/<http://localhost:8080/axis2/services/HelloWorld%22/>
>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

*xsd  file is* :
 *-* <http://localhost:8080/axis2/services/HelloWorld?xsd#> <xs:schema
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://hello/xsd" xmlns:axis2="http://hello" xmlns:ns="
http://hello/xsd" xmlns:ns0="http://hello/xsd" xmlns:ns1="
http://org.apache.axis2/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="sayHello">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="str_1" nillable="true" type="xs:string" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="sayHelloResponse">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="return" nillable="true" type="xs:int" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>


*And my client side code is : client is developed using eclips 3.1 *
**
*HelloWorld.java*

import java.util.Iterator;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;

import javax.xml.namespace.QName;
public class HelloWorld {

 /**
  * @param args
  *
  */

 public static void main(String[] args) throws Exception {
  System.out.println("Start -- 1");
  String str1="Rizwan";



  WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  String wsdlloc="http://localhost:8080/axis2/services/HelloWorld?wsdl";
  System.out.println(" -- 2 --");
  WSIFService service = factory.getService(wsdlloc,null,null ,"
http://hello","HelloWorldPortType");
  service.mapType(new QName("
http://hello/xsd","HelloWorld"),Class.forName("clientsidecode.HelloClient.HelloWorld<http://hello/xsd%22,%22HelloWorld%22),Class.forName(%22clientsidecode.HelloClient.HelloWorld>
"));
  WSIFPort port = service.getPort("HelloWorldSOAP11port_http");
  System.out.println("-- 3--");
  WSIFOperation operation=port.createOperation("sayHello");
  WSIFMessage input = operation.createInputMessage("str_1");
  WSIFMessage output =operation.createOutputMessage();
  WSIFMessage fault = operation.createFaultMessage();
  input.setObjectPart("str_1",str1);
  String str_2="Hi";
  System.out.println("Input Message"+input);
  System.out.println("Input parts : "+input.getObjectPart("str_1"));
  //input.setObjectPart("part1",str_2);

  if(operation.executeRequestResponseOperation(input,output,fault))
  {
   System.out.println("Result : "+output.getIntPart("return"));
  }
  // TODO Auto-generated method stub
  System.out.println("End");

 }

}

All the pre-required jar of the WSIF are being installed.

When i run the client the following error occured. Please suggest me where
will be the exact problem is.




*OUTPUT :*

Start -- 1

Exception in thread "main"
*org.apache.wsif.WSIFException*: exception on AXIS invoke: Exception
occurred while trying to invoke service method sayHello; nested exception
is:

Exception occurred while trying to invoke service method sayHello

at
org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeAXISDocStyle(Unknown
Source)

-- 2 --

- WSIF0006W: Multiple WSIFProvider found supporting the same namespace URI '
http://schemas.xmlsoap.org/wsdl/soap/'. Found ('
org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis,
org.apache.wsif.providers.soap.apachesoap.WSIFDynamicProvider_ApacheSOAP')

- WSIF0007I: Using WSIFProvider '
org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis'
for namespaceURI 'http://schemas.xmlsoap.org/wsdl/soap/'

-- 3--

Input Messageorg.apache.wsif.base.WSIFDefaultMessage@c2a132 name:str_1

Input parts : Rizwan

at
org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeRequestResponseOperation(Unknown
Source)

at
org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.executeRequestResponseOperation(Unknown
Source)

at clientsidecode.HelloClient.HelloWorld.main(
*HelloWorld.java:41*)

Caused by: Exception occurred while trying to invoke service method sayHello

at org.apache.axis.message.SOAPFaultBuilder.endElement(
*SOAPFaultBuilder.java:135*)

at org.apache.axis.encoding.DeserializationContextImpl.endElement(
*DeserializationContextImpl.java:942*)

at org.apache.crimson.parser.Parser2.maybeElement(
*Parser2.java:1528*)

at org.apache.crimson.parser.Parser2.content(
*Parser2.java:1779*)

at org.apache.crimson.parser.Parser2.maybeElement(
*Parser2.java:1507*)

at org.apache.crimson.parser.Parser2.content(
*Parser2.java:1779*)

at org.apache.crimson.parser.Parser2.maybeElement(
*Parser2.java:1507*)

at org.apache.crimson.parser.Parser2.parseInternal(
*Parser2.java:500*)

at org.apache.crimson.parser.Parser2.parse(
*Parser2.java:305*)

at org.apache.crimson.parser.XMLReaderImpl.parse(
*XMLReaderImpl.java:442*)

at javax.xml.parsers.SAXParser.parse(
*SAXParser.java:375*)

at org.apache.axis.encoding.DeserializationContextImpl.parse(
*DeserializationContextImpl.java:232*)

at org.apache.axis.SOAPPart.getAsSOAPEnvelope(
*SOAPPart.java:546*)

at org.apache.axis.Message.getSOAPEnvelope(
*Message.java:377*)

at org.apache.axis.client.Call.invokeEngine(
*Call.java:2132*)

at org.apache.axis.client.Call.invoke(
*Call.java:2102*)

at org.apache.axis.client.Call.invoke(
*Call.java:1851*)

at org.apache.axis.client.Call.invoke(
*Call.java:1777*)

at org.apache.axis.client.Call.invoke(
*Call.java:1315*)

... 4 more