You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by ti...@uk.andersen.com on 2001/11/09 14:28:23 UTC

SOAP::Lite server and Apache SOAP client


All,

I am trying to get a SOAP::Lite server working with and Apache SOAP client. It
is only a basic example but  I am getting the following error when running the
client. I can hit the SOAP::Lite server with a SOAP::Lite client with no
problems and the string is returned however, when I try and hit it with the
Apache SOAP client, I get the following error returned:

invoke service
  URL= http://10.117.149.207/twiki/bin/TWikiServices.pl
  URN =TWikiServices

Getting the response.......

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

     at java.lang.StringBuffer.charAt(StringBuffer.java:276)

     at org.apache.soap.util.net.HTTPUtils.post(HTTPUtils.java, Compiled Code)

     at
org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:282)

     at org.apache.soap.rpc.Call.invoke(Call.java:205)

     at soapclient.MailExtractor.main(MailExtractor.java:28)

Exception in thread "main"


Please can anyone point me in the right direction for getting this simple demo
running.

Regards,

Timo




The following code elements are being used...

The java client:

package soapclient;

import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;

public class MailExtractor
  {
    public static void main( String[] args ) throws Exception
      {
        URL url = new URL( "http://10.117.149.207/twiki/bin/TWikiServices.pl" );
        String urn = "TWikiServices";
        Call call = new Call(); // prepare the service invocation
        call.setTargetObjectURI( urn );
        call.setMethodName( "hi" );
        call.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC );
        try {
          System.out.println( "invoke service\n" + "  URL= " + url + "\n  URN ="
 + urn );
          System.out.println("Getting the response.......");
          Response response = call.invoke( url, "" ); // invoke the service
          if( !response.generatedFault() ) {
              System.out.println("got a result.....");
              Parameter result = response.getReturnValue(); // response was OK
              System.out.println( "Result= " + result.getValue() );
          } else {
            System.out.println("got a fault.....");
            Fault f = response.getFault(); // an error occurred
            System.err.println( "Fault= " + f.getFaultCode() + ", " +
f.getFaultString() );
          }
          System.out.println("Finished process....");
       } catch( SOAPException e ) {// call could not be sent properly
          System.err.println( "Caught SOAPException= " + e.getFaultCode() + ", "
 + e.getMessage() );
       }
     }
   }

The SOAP::Lite server:

#!perl -w
# -- SOAP::Lite -- guide.soaplite.com -- Copyright (C) 2001 Paul Kulchenko --

use strict;

use SOAP::Transport::HTTP;

SOAP::Transport::HTTP::CGI
     -> dispatch_to('TWikiServices')
     -> handle;


package TWikiServices;


##
#subroutine for testing the SOAP server
##
sub hi
{
     my $var = SOAP::Data->type(string => 123);
     return $var;
}





*******************Internet Email Confidentiality Footer*******************
The UK firms of Arthur Andersen, Andersen Corporate Finance and Andersen Private
Client Services are authorised by the Institute of Chartered Accountants in
England and Wales to carry on investment business.  For each firm, a list of
partners is available at 180 Strand, London, WC2R 1BL (principal place of
business).

Privileged/Confidential Information may be contained in this message.  If you
are not the addressee indicated in this message (or responsible for delivery of
the message to such person), you may not copy or deliver this message to anyone.
In such case, you should destroy this message and kindly notify the sender by
reply email. Please advise immediately if you or your employer does not consent
to Internet email for messages of this kind.  Opinions, conclusions and other
information in this message that do not relate to the official business of my
firm shall be understood as neither given nor endorsed by it.