From: <ps...@us...> - 2008-12-10 08:03:24
|
Revision: 1472 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1472&view=rev Author: psha Date: 2008-12-10 08:03:17 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Add support for WS-Addressing WSDL Binding Search for Action attributes not only in WSA*.ADDRESS namespaces but also in WSAW*. wsaw is used by Globus Toolkit 4.2+ See http://www.w3.org/TR/ws-addr-wsdl/ for wsaw definition. Modified Paths: -------------- trunk/wstools/Namespaces.py trunk/wstools/WSDLTools.py Modified: trunk/wstools/Namespaces.py =================================================================== --- trunk/wstools/Namespaces.py 2008-12-10 07:57:09 UTC (rev 1471) +++ trunk/wstools/Namespaces.py 2008-12-10 08:03:17 UTC (rev 1472) @@ -183,6 +183,15 @@ WSA = WSA200408 WSA_LIST = (WSA200508, WSA200408, WSA200403, WSA200303) +class _WSAW(str): + """ Define ADDRESS attribute to be compatible with WSA* layout """ + ADDRESS = "" + +WSAW200605 = _WSAW("http://www.w3.org/2006/05/addressing/wsdl") +WSAW200605.ADDRESS = WSAW200605 # Compatibility hack + +WSAW_LIST = (WSAW200605,) + class WSP: POLICY = "http://schemas.xmlsoap.org/ws/2002/12/policy" Modified: trunk/wstools/WSDLTools.py =================================================================== --- trunk/wstools/WSDLTools.py 2008-12-10 07:57:09 UTC (rev 1471) +++ trunk/wstools/WSDLTools.py 2008-12-10 08:03:17 UTC (rev 1472) @@ -11,7 +11,7 @@ import weakref from cStringIO import StringIO -from Namespaces import OASIS, XMLNS, WSA, WSA_LIST, WSRF_V1_2, WSRF +from Namespaces import OASIS, XMLNS, WSA, WSA_LIST, WSAW_LIST, WSRF_V1_2, WSRF from Utility import Collection, CollectionNS, DOM, ElementProxy, basejoin from XMLSchema import XMLSchema, SchemaReader, WSDLToolsAdapter @@ -596,7 +596,7 @@ docs = GetDocumentation(item) msgref = DOM.getAttr(item, 'message') message = ParseQName(msgref, item) - for WSA in WSA_LIST: + for WSA in WSA_LIST + WSAW_LIST: action = DOM.getAttr(item, 'Action', WSA.ADDRESS, None) if action: break operation.setInput(message, name, docs, action) @@ -607,7 +607,7 @@ docs = GetDocumentation(item) msgref = DOM.getAttr(item, 'message') message = ParseQName(msgref, item) - for WSA in WSA_LIST: + for WSA in WSA_LIST + WSAW_LIST: action = DOM.getAttr(item, 'Action', WSA.ADDRESS, None) if action: break operation.setOutput(message, name, docs, action) @@ -617,7 +617,7 @@ docs = GetDocumentation(item) msgref = DOM.getAttr(item, 'message') message = ParseQName(msgref, item) - for WSA in WSA_LIST: + for WSA in WSA_LIST + WSAW_LIST: action = DOM.getAttr(item, 'Action', WSA.ADDRESS, None) if action: break operation.addFault(message, name, docs, action) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-03-31 18:28:00
|
Revision: 1483 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1483&view=rev Author: lclement Date: 2009-03-31 18:27:55 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Added binary attachment support (client only) Modified Paths: -------------- trunk/wstools/Namespaces.py trunk/wstools/Utility.py Added Paths: ----------- trunk/wstools/MIMEAttachment.py Added: trunk/wstools/MIMEAttachment.py =================================================================== --- trunk/wstools/MIMEAttachment.py (rev 0) +++ trunk/wstools/MIMEAttachment.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -0,0 +1,110 @@ +#TODO add the license +#I had to rewrite this class because the python MIME email.mime (version 2.5) +#are buggy, they use \n instead \r\n for new line which is not compliant +#to standard! +# http://bugs.python.org/issue5525 + +#TODO do not load all the message in memory stream it from the disk + +import re +import random +import sys + + +#new line +NL='\r\n' + +_width = len(repr(sys.maxint-1)) +_fmt = '%%0%dd' % _width + +class MIMEMessage: + + def __init__(self): + self._files = [] + self._xmlMessage = "" + self._startCID = "" + self._boundary = "" + + def makeBoundary(self): + #create the boundary + msgparts = [] + msgparts.append(self._xmlMessage) + for i in self._files: + msgparts.append(i.read()) + #this sucks, all in memory + alltext = NL.join(msgparts) + self._boundary = _make_boundary(alltext) + #maybe I can save some memory + del alltext + del msgparts + self._startCID = "<" + (_fmt % random.randrange(sys.maxint)) + (_fmt % random.randrange(sys.maxint)) + ">" + + + def toString(self): + '''it return a string with the MIME message''' + if len(self._boundary) == 0: + #the makeBoundary hasn't been called yet + self.makeBoundary() + #ok we have everything let's start to spit the message out + #first the XML + returnstr = NL + "--" + self._boundary + NL + returnstr += "Content-Type: text/xml; charset=\"us-ascii\"" + NL + returnstr += "Content-Transfer-Encoding: 7bit" + NL + returnstr += "Content-Id: " + self._startCID + NL + NL + returnstr += self._xmlMessage + NL + #then the files + for file in self._files: + returnstr += "--" + self._boundary + NL + returnstr += "Content-Type: application/octet-stream" + NL + returnstr += "Content-Transfer-Encoding: binary" + NL + returnstr += "Content-Id: <" + str(id(file)) + ">" + NL + NL + file.seek(0) + returnstr += file.read() + NL + #closing boundary + returnstr += "--" + self._boundary + "--" + NL + return returnstr + + def attachFile(self, file): + ''' + it adds a file to this attachment + ''' + self._files.append(file) + + def addXMLMessage(self, xmlMessage): + ''' + it adds the XML message. we can have only one XML SOAP message + ''' + self._xmlMessage = xmlMessage + + def getBoundary(self): + ''' + this function returns the string used in the mime message as a + boundary. First the write method as to be called + ''' + return self._boundary + + def getStartCID(self): + ''' + This function returns the CID of the XML message + ''' + return self._startCID + + +def _make_boundary(text=None): + #some code taken from python stdlib + # Craft a random boundary. If text is given, ensure that the chosen + # boundary doesn't appear in the text. + token = random.randrange(sys.maxint) + boundary = ('=' * 10) + (_fmt % token) + '==' + if text is None: + return boundary + b = boundary + counter = 0 + while True: + cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE) + if not cre.search(text): + break + b = boundary + '.' + str(counter) + counter += 1 + return b + Modified: trunk/wstools/Namespaces.py =================================================================== --- trunk/wstools/Namespaces.py 2009-03-31 18:27:03 UTC (rev 1482) +++ trunk/wstools/Namespaces.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -24,7 +24,9 @@ XSD1 = "http://www.w3.org/1999/XMLSchema" XSD2 = "http://www.w3.org/2000/10/XMLSchema" XSD3 = "http://www.w3.org/2001/XMLSchema" - XSD_LIST = [ XSD1, XSD2, XSD3 ] + #AXIS attachment implementation details + AXIS = "http://xml.apache.org/xml-soap" + XSD_LIST = [ XSD1, XSD2, XSD3, AXIS] XSI1 = "http://www.w3.org/1999/XMLSchema-instance" XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance" XSI3 = "http://www.w3.org/2001/XMLSchema-instance" Modified: trunk/wstools/Utility.py =================================================================== --- trunk/wstools/Utility.py 2009-03-31 18:27:03 UTC (rev 1482) +++ trunk/wstools/Utility.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -976,6 +976,7 @@ def createAttributeNS(self, namespace, name, value): document = self._getOwnerDocument() + ##this function doesn't exist!! it has only two arguments attrNode = document.createAttributeNS(namespace, name, value) def setAttributeNS(self, namespaceURI, localName, value): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-04-07 00:02:17
|
Revision: 1486 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1486&view=rev Author: lclement Date: 2009-04-07 00:02:02 +0000 (Tue, 07 Apr 2009) Log Message: ----------- Bug fix in the File attachment Modified Paths: -------------- trunk/wstools/Namespaces.py trunk/wstools/XMLSchema.py Modified: trunk/wstools/Namespaces.py =================================================================== --- trunk/wstools/Namespaces.py 2009-04-02 01:08:10 UTC (rev 1485) +++ trunk/wstools/Namespaces.py 2009-04-07 00:02:02 UTC (rev 1486) @@ -24,9 +24,7 @@ XSD1 = "http://www.w3.org/1999/XMLSchema" XSD2 = "http://www.w3.org/2000/10/XMLSchema" XSD3 = "http://www.w3.org/2001/XMLSchema" - #AXIS attachment implementation details - AXIS = "http://xml.apache.org/xml-soap" - XSD_LIST = [ XSD1, XSD2, XSD3, AXIS] + XSD_LIST = [ XSD1, XSD2, XSD3] XSI1 = "http://www.w3.org/1999/XMLSchema-instance" XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance" XSI3 = "http://www.w3.org/2001/XMLSchema-instance" @@ -142,6 +140,13 @@ BASEFAULTS = WSRF_V1_2.BASEFAULTS.XSD_DRAFT1 +class APACHE: + '''This name space is defined by AXIS and it is used for the TC in TCapache.py, + Map and file attachment (DataHandler) + ''' + AXIS_NS = "http://xml.apache.org/xml-soap" + + class WSTRUST: BASE = "http://schemas.xmlsoap.org/ws/2004/04/trust" ISSUE = "http://schemas.xmlsoap.org/ws/2004/04/trust/Issue" Modified: trunk/wstools/XMLSchema.py =================================================================== --- trunk/wstools/XMLSchema.py 2009-04-02 01:08:10 UTC (rev 1485) +++ trunk/wstools/XMLSchema.py 2009-04-07 00:02:02 UTC (rev 1486) @@ -15,7 +15,7 @@ ident = "$Id$" import types, weakref, sys, warnings -from Namespaces import SCHEMA, XMLNS, SOAP +from Namespaces import SCHEMA, XMLNS, SOAP, APACHE from Utility import DOM, DOMException, Collection, SplitQName, basejoin from StringIO import StringIO @@ -37,7 +37,7 @@ ATTRIBUTES = 'attr_decl' ELEMENTS = 'elements' MODEL_GROUPS = 'model_groups' -BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST +BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST + [APACHE.AXIS_NS] def GetSchema(component): """convience function for finding the parent XMLSchema instance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |