Re: [BangPypers] Writing a Python Client to access a web service.
http://pywebsvcs.sourceforge.net/ You need SOAPpy for accessing a SOAP based web-service. --Anand On Tue, Jun 3, 2008 at 2:37 PM, Heshan Suriyaarachchi [EMAIL PROTECTED] wrote: Hi, I have written a web service and have deployed it using Apache Axis2. What I want to do is to invoke this service using a python script. Can anyone point me in the direction of how to do this. I will be grateful If anyone can give me a web reference to a code sample.I can do this with java. To give you an idea of what kind of a thing I want to do , I am attaching my java client code below. import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.client.Options; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.impl.builder.StAXOMBuilder; import javax.xml.stream.XMLStreamException; import java.io.ByteArrayInputStream; public class myClient { private static EndpointReference targetEPR = new EndpointReference(http://localhost:8070/axis2/services/annotationScript/deduct;); //http://localhost:8080/axis2/services/annotationScript/f public static OMElement getPayload() throws XMLStreamException { String str1 = fa4/a/f; String str2 = deductvar11.8/var1var24.87594/var2/deduct; String str3 = addvar11.8/var1var24.87594/var2/add; StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(str2.getBytes())); return builder.getDocumentElement(); } public static void main(String[] args) throws Exception { ServiceClient sender = new ServiceClient(); Options op = new Options(); op.setTo(targetEPR); sender.setOptions(op); OMElement response = sender.sendReceive(getPayload()); System.out.println(response); } } Thanx in advance -- Regards, Heshan Suriyaarachchi ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- -Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Writing a Python Client to access a web service.
Hi, I have written a web service and have deployed it using Apache Axis2. What I want to do is to invoke this service using a python script. Can anyone point me in the direction of how to do this. I will be grateful If anyone can give me a web reference to a code sample.I can do this with java. To give you an idea of what kind of a thing I want to do , I am attaching my java client code below. import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.client.Options; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.impl.builder.StAXOMBuilder; import javax.xml.stream.XMLStreamException; import java.io.ByteArrayInputStream; public class myClient { private static EndpointReference targetEPR = new EndpointReference( http://localhost:8070/axis2/services/annotationScript/deduct;); //http://localhost:8080/axis2/services/annotationScript/f public static OMElement getPayload() throws XMLStreamException { String str1 = fa4/a/f; String str2 = deductvar11.8/var1var24.87594/var2/deduct; String str3 = addvar11.8/var1var24.87594/var2/add; StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(str2.getBytes())); return builder.getDocumentElement(); } public static void main(String[] args) throws Exception { ServiceClient sender = new ServiceClient(); Options op = new Options(); op.setTo(targetEPR); sender.setOptions(op); OMElement response = sender.sendReceive(getPayload()); System.out.println(response); } } Thanx in advance -- Regards, Heshan Suriyaarachchi ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Writing a Python Client to access a web service.
On Tue, Jun 3, 2008 at 2:37 PM, Heshan Suriyaarachchi [EMAIL PROTECTED] wrote: Hi, I have written a web service and have deployed it using Apache Axis2. What I want to do is to invoke this service using a python script. Can anyone point me in the direction of how to do this. I will be grateful If anyone can give me a web reference to a code sample.I can do this with java. To give you an idea of what kind of a thing I want to do , I am attaching my java client code below. import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.client.Options; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.impl.builder.StAXOMBuilder; import javax.xml.stream.XMLStreamException; import java.io.ByteArrayInputStream; public class myClient { private static EndpointReference targetEPR = new EndpointReference(http://localhost:8070/axis2/services/annotationScript/deduct;); //http://localhost:8080/axis2/services/annotationScript/f public static OMElement getPayload() throws XMLStreamException { String str1 = fa4/a/f; String str2 = deductvar11.8/var1var24.87594/var2/deduct; String str3 = addvar11.8/var1var24.87594/var2/add; StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(str2.getBytes())); return builder.getDocumentElement(); } public static void main(String[] args) throws Exception { ServiceClient sender = new ServiceClient(); Options op = new Options(); op.setTo(targetEPR); sender.setOptions(op); OMElement response = sender.sendReceive(getPayload()); System.out.println(response); } } Dive into python has a good tutorial on webservices using python. http://www.diveintopython.org/soap_web_services/ The rest of the book is pretty readable as well. -- Vinayak ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers