0
votes

I have the following situation, I have to use a web service written in python with the use of soaplib in Java. I can import the web service just fine in eclipse, but when I try to call a method of the web service I get the following error message ...


    AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode: 
     faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog.
     faultActor: 
     faultNode: 
     faultDetail:

So I tried to build my own little web service using soaplib to try this out. Here is the web service server running with soaplib and the internal http server. Simple method


    import soaplib
    from soaplib.core.service import rpc, DefinitionBase
    from soaplib.core.model.primitive import String, Integer
    from soaplib.core.server import wsgi
    from soaplib.core.model.clazz import Array
    from soaplib.core.service import soap

    class HelloWorldService(DefinitionBase):
        @soap(String,_returns=String)
        def say_hello(self,name):
            results = 'Hello, %s'%name
            print('Hello, %s' % name)
            return results

    if __name__=='__main__':
        try:
            from wsgiref.simple_server import make_server
            soap_application = soaplib.core.Application([HelloWorldService], 'tns')
            wsgi_application = wsgi.Application(soap_application)
            server = make_server('pc-frank', 7789, wsgi_application)
            server.serve_forever()
        except ImportError:
            print "Error: example server code requires Python >= 2.5"

and this is the java class I try to use


    import java.rmi.RemoteException;
    import static java.lang.System.out;
    import tns.*;

    public class testws {
        public static void main(String[] args){
            ApplicationProxy ws = new ApplicationProxy();
            try {
                String test   = ws.say_hello("world");
                out.println(test);
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }   
    }

Any help is really appreciated!

1
I actually ended up using github.com/arskom/rpclib which works just great, so I recommend that to anyone trying to create a webservice with python.flazzarini

1 Answers

0
votes

It sounds like either the request or the response is not parsing. I would capture both and run them through a verification tool. There are a lot of them around online that allow you to paste the XML in and see why it's not validating.