Loading ...
Sorry, an error occurred while loading the content.

498Java client connecting to perl soap::lite server.

Expand Messages
  • Steve McKay
    Jun 19, 2001
    • 0 Attachment
      I'm are trying to write a java soap client (using apache soap) to
      connect to a perl soap::lite server. Perl works no problem. Java gives
      an error.

      Following is the perl soap::lite server:

      #!/usr/bin/perl -w
      use strict;

      use SOAP::Transport::HTTP;

      my $daemon = SOAP::Transport::HTTP::Daemon
      -> new (LocalAddr => '127.0.0.1',
      LocalPort => "12001",
      Reuse => 1)
      -> on_action(sub { print "$_[1]\:\:$_[2]\n";})
      ->dispatch_to('/soap/modules','[\w:]+');

      print "SOAP server running on ".$daemon->url."\n";
      $daemon->handle;

      Following is the java client:

      import java.util.*;
      import java.net.*;
      import org.apache.soap.*;
      import org.apache.soap.encoding.*;
      import org.apache.soap.encoding.soapenc.*;
      import org.apache.soap.rpc.*;

      public class test
      {
      public static void main(String[] args) throws Exception
      {
      // Address of SOAP router
      URL url=new URL("http://127.0.0.1:12001");

      // Build the call
      Call call=new Call();
      call.setSOAPMappingRegistry(new SOAPMappingRegistry());
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
      call.setTargetObjectURI("urn:Demo");
      call.setMethodName("Hello");

      // Invoke the call to the SOAP server
      Response resp=call.invoke(url,"");
      // Print the returned string
      boolean status=resp.generatedFault();
      Parameter ret=resp.getReturnValue();
      Object value=ret.getValue();
      System.out.println(value);
      }
      }


      Whenever I try to run the client, I get the following:

      Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Client;
      msg=Error parsing HTTP status line "<?xml version="1.0"
      encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode
      xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultstring
      xsi:type="xsd:string">Application failed during request deserialization:
      ": java.lang.NumberFormatException: version="1.0";
      targetException=java.lang.IllegalArgumentException: Error parsing HTTP
      status line "<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode
      xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultstring
      xsi:type="xsd:string">Application failed during request deserialization:
      ": java.lang.NumberFormatException: version="1.0"]
      at
      org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:324)
      at org.apache.soap.rpc.Call.invoke(Call.java:205)
      at test.main(test.java:23)

      Process test exited abnormally with code 1


      Does anyone have a java soap client talking to a perl soap::lite server?
      If so, could you reply with your client?


      Thanks in advance.