From: <bov...@us...> - 2007-01-26 18:45:58
|
Revision: 1341 http://svn.sourceforge.net/pywebsvcs/?rev=1341&view=rev Author: boverhof Date: 2007-01-26 10:30:24 -0800 (Fri, 26 Jan 2007) Log Message: ----------- M test/wsdl2py/config.txt A test/wsdl2py/test_BasicComm.py A test/wsdl2py/servers/BasicServer.py A test/wsdl2py/BasicComm.wsdl M ZSI/dispatch.py M ZSI/ServiceContainer.py merge trunk w/previous commit Modified Paths: -------------- trunk/zsi/ZSI/ServiceContainer.py trunk/zsi/ZSI/dispatch.py trunk/zsi/test/wsdl2py/config.txt Added Paths: ----------- trunk/zsi/test/wsdl2py/BasicComm.wsdl trunk/zsi/test/wsdl2py/servers/BasicServer.py trunk/zsi/test/wsdl2py/test_BasicComm.py Modified: trunk/zsi/ZSI/ServiceContainer.py =================================================================== --- trunk/zsi/ZSI/ServiceContainer.py 2007-01-26 18:07:53 UTC (rev 1340) +++ trunk/zsi/ZSI/ServiceContainer.py 2007-01-26 18:30:24 UTC (rev 1341) @@ -113,7 +113,7 @@ # If No response just return. if result is None: - return + return SendResponse('', **kw) sw = SoapWriter(nsdict=nsdict) try: Modified: trunk/zsi/ZSI/dispatch.py =================================================================== --- trunk/zsi/ZSI/dispatch.py 2007-01-26 18:07:53 UTC (rev 1340) +++ trunk/zsi/ZSI/dispatch.py 2007-01-26 18:30:24 UTC (rev 1341) @@ -191,10 +191,16 @@ '''Send some XML. ''' self.send_response(code) - self.send_header('Content-type', 'text/xml; charset="utf-8"') - self.send_header('Content-Length', str(len(text))) + + if text: + self.send_header('Content-type', 'text/xml; charset="utf-8"') + self.send_header('Content-Length', str(len(text))) + self.end_headers() - self.wfile.write(text) + + if text: + self.wfile.write(text) + self.wfile.flush() def send_fault(self, f, code=500): Added: trunk/zsi/test/wsdl2py/BasicComm.wsdl =================================================================== --- trunk/zsi/test/wsdl2py/BasicComm.wsdl (rev 0) +++ trunk/zsi/test/wsdl2py/BasicComm.wsdl 2007-01-26 18:30:24 UTC (rev 1341) @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<definitions + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" + xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="urn:ZSI:examples" + targetNamespace="urn:ZSI:examples" > + <types> + <xsd:schema elementFormDefault="qualified" targetNamespace="urn:ZSI:examples"> + <xsd:element name="Basic"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="BasicIn" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="BasicResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="BasicResult" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="BasicOneWay"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="BasicIn" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:schema> + </types> + + <message name="BasicRequest"> + <part name="parameters" element="tns:Basic" /> + </message> + <message name="BasicResponse"> + <part name="parameters" element="tns:BasicResponse"/> + </message> + <message name="BasicOneWayRequest"> + <part name="parameters" element="tns:BasicOneWay" /> + </message> + + <portType name="BasicServer"> + <operation name="Basic"> + <input message="tns:BasicRequest"/> + <output message="tns:BasicResponse"/> + </operation> + <operation name="BasicOneWay"> + <input message="tns:BasicOneWayRequest"/> + </operation> + </portType> + + <binding name="BasicServer" type="tns:BasicServer"> + <soap:binding style="document" + transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="Basic"> + <soap:operation soapAction="Basic"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + <operation name="BasicOneWay"> + <soap:operation soapAction="BasicOneWay"/> + <input> + <soap:body use="literal"/> + </input> + </operation> + </binding> + + <service name="BasicServer"> + <port name="BasicServer" binding="tns:BasicServer"> + <soap:address location="http://localhost:7000"/> + </port> + </service> + +</definitions> Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2007-01-26 18:07:53 UTC (rev 1340) +++ trunk/zsi/test/wsdl2py/config.txt 2007-01-26 18:30:24 UTC (rev 1341) @@ -33,6 +33,7 @@ twisted = False test_WhiteMesa = servers/WhiteMesa.py test_Echo = servers/EchoServer.py +test_BasicComm = servers/BasicServer.py test_SquareService = servers/SquareService.py test_DateService = servers/DateService.py test_FinancialService = servers/FinancialService.py @@ -117,7 +118,7 @@ document = True literal = True broke = False -tests = test_MapPoint test_OpcDaGateway test_Echo test_AWSECommerceService test_FinancialService +tests = test_MapPoint test_Echo test_AWSECommerceService test_FinancialService test_BasicComm test_Manufacturer test_Racing [doc_literal_broke] document = True @@ -151,6 +152,7 @@ test_Sabre = http://webservices.sabre.com/wsdl/sabreXML1.0.00/res/SessionCreateRQ.wsdl test_Echo = ../../samples/Echo/Echo.wsdl +test_BasicComm = BasicComm.wsdl test_Choice = test_Choice.xsd test_Attributes = test_Attributes.xsd test_DerivedTypes = test_DerivedTypes.xsd Added: trunk/zsi/test/wsdl2py/servers/BasicServer.py =================================================================== --- trunk/zsi/test/wsdl2py/servers/BasicServer.py (rev 0) +++ trunk/zsi/test/wsdl2py/servers/BasicServer.py 2007-01-26 18:30:24 UTC (rev 1341) @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import sys +from ZSI.ServiceContainer import AsServer +from BasicServer_server import BasicServer + +""" +BasicServer example service + +WSDL: BasicComm.wsdl + +""" + + +class Service(BasicServer): + def soap_Basic(self, ps): + response = BasicServer.soap_Basic(self, ps) + response._BasicResult = self.request._BasicIn + return response + + def soap_BasicOneWay(self, ps): + return BasicServer.soap_BasicOneWay(self, ps) + + +if __name__ == "__main__" : + port = int(sys.argv[1]) + AsServer(port, (Service('test'),)) Added: trunk/zsi/test/wsdl2py/test_BasicComm.py =================================================================== --- trunk/zsi/test/wsdl2py/test_BasicComm.py (rev 0) +++ trunk/zsi/test/wsdl2py/test_BasicComm.py 2007-01-26 18:30:24 UTC (rev 1341) @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +import os, sys, unittest +from ServiceTest import main, ServiceTestCase, ServiceTestSuite +from ZSI import FaultException +from ConfigParser import ConfigParser, NoSectionError, NoOptionError +""" +Unittest + +WSDL: BasicComm.wsdl +""" +CONFIG_FILE = 'config.txt' +CONFIG_PARSER = ConfigParser() +SECTION_DISPATCH = 'dispatch' + +CONFIG_PARSER.read(CONFIG_FILE) + +# General targets +def dispatch(): + """Run all dispatch tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(BasicCommTestCase, 'test_dispatch')) + return suite + +def local(): + """Run all local tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(BasicCommTestCase, 'test_local')) + return suite + +def net(): + """Run all network tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(BasicCommTestCase, 'test_net')) + return suite + +def all(): + """Run all tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(BasicCommTestCase, 'test_')) + return suite + + +class BasicCommTestCase(ServiceTestCase): + name = "test_BasicComm" + client_file_name = "BasicServer_client.py" + types_file_name = "BasicServer_types.py" + server_file_name = "BasicServer_server.py" + + def __init__(self, methodName): + ServiceTestCase.__init__(self, methodName) + self.wsdl2py_args.append('-b') + + def test_local_Basic(self): + msg = self.client_module.BasicRequest() + rsp = self.client_module.BasicResponse() + + def test_dispatch_Basic(self): + loc = self.client_module.BasicServerLocator() + port = loc.getBasicServer(**self.getPortKWArgs()) + + msg = self.client_module.BasicRequest() + msg._BasicIn = 'bla bla bla' + rsp = port.Basic(msg) + self.failUnless(rsp._BasicResult == msg._BasicIn, "Bad Echo") + + # test whether we get an HTTP response on a message with + # no soap response. + import httplib + msg = u""" + <SOAP-ENV:Envelope + xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" + xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <SOAP-ENV:Header></SOAP-ENV:Header> + <SOAP-ENV:Body xmlns:ns1="urn:ZSI:examples"> + <ns1:BasicOneWay> + <ns1:BasicIn>bla bla bla</ns1:BasicIn> + </ns1:BasicOneWay> + </SOAP-ENV:Body> + </SOAP-ENV:Envelope>""".encode('utf-8') + headers = {"Content-type": 'text/xml; charset="utf-8"', 'Content-Length': str(len(msg))} + + host = CONFIG_PARSER.get(SECTION_DISPATCH, 'host') + port = CONFIG_PARSER.get(SECTION_DISPATCH, 'port') + path = CONFIG_PARSER.get(SECTION_DISPATCH, 'path') + + conn = httplib.HTTPConnection("%s:%s" % (host, port)) + conn.request('POST', '/' + path, msg, headers) + try: + response = conn.getresponse() + except httplib.BadStatusLine: + conn.close() + self.fail('No HTTP Response') + + conn.close() + self.failUnless(response.status == 200, 'Wrong HTTP Result') + + + +if __name__ == "__main__" : + main() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |