Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Joshua Boverhof <jrboverhof <at> lbl.gov>
Subject: Re: .net and zsi -- namespace prefix problem?
Newsgroups: gmane.comp.python.pywebsvcs.general
Date: Thursday 31st May 2007 18:55:06 UTC (over 10 years ago)
the "right" way to change XML formatting is to change the  
ElementProxy class.  Here is an example of how to declare namespaces  
in the node that requires it, and not have them percolate up to the  
parent.

This has nothing to do with c14n, although it makes sense that you  
would think it is involved.

-josh



from ZSI.wstools.Utility import ElementProxy
class XElementProxy(ElementProxy):

     def createElementNS(self, namespace, qname):
         '''
         Keyword arguments:
             namespace -- namespace of element to create
             qname -- qualified name of new element
         '''
         document = self._getOwnerDocument()
         node = document.createElementNS(namespace, qname)
         return XElementProxy(self.sw, node)

     def createAppendElement(self, namespaceURI, localName,  
prefix=None):
         '''Create a new element (namespaceURI,name), append it
            to current node, and return the newly created node.
         Keyword arguments:
             namespaceURI -- namespace of element to create
             localName -- local name of new element
             prefix -- if namespaceURI is not defined, declare  
prefix.  defaults
                 to 'ns1' if left unspecified.
         '''
         declare = False
         qualifiedName = localName
         if prefix is not None:
             raise NotImplementedError, 'sorry cannot specify the  
prefix'

         if namespaceURI and prefix is None:
             try:
                 prefix = self._getPrefix(self._getNode(), namespaceURI)
             except:
                 prefix = self._getUniquePrefix()
                 qualifiedName = '%s:%s' %(prefix, localName)
                 node = self.createElementNS(namespaceURI,  
qualifiedName)
                 node.setNamespaceAttribute(prefix, namespaceURI)
                 self._appendChild(node=node._getNode())
                 return node

             qualifiedName = '%s:%s' %(prefix, localName)

         node = self.createElementNS(namespaceURI, qualifiedName)
         self._appendChild(node=node._getNode())
         return node


loc = CLI.StoreWebServiceLocator()
port = loc.getStoreWebServiceSoap(url="http://www.google.com",
     tracefile=sys.stdout, writerclass=XElementProxy)






On May 27, 2007, at 12:53 AM, Kenji Noguchi wrote:

> after all I added a few lines of ugly hook (regex and string
> replacements) to SoapWriter.__str__ so that the client generates XML
> in the specific format. Now it works!!
>
> I think the right way is to modify c14n.py but it seems not easy.
>
> -kenji
>
> 2007/5/23, Kenji Noguchi :
>> hi again,
>>
>> I checked out the latest revision from svn, and the problem 1 and 2
>> were solved by following what Joshua explained.  Thanks.
>>
>> 2007/5/23, Joshua Boverhof :
>>> 
>>> http://schemas.xmlsoap.org/soap/

>>> envelope/"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>>    
>>>      
>>>        soap:Server
>>>        There was an exception running the extensions
>>> specified in the config file. --> Object reference not set to an
>>> instance of an object.
>>>        
>>>      
>>>    
>>> 
>>>
>>>
>>> Here is what I get. This error doesn't appear to have anything to do
>>> with the default namespace?  Is this what you get?
>>
>> Yes, this is what I got, too.  This is how I found out the  
>> namespace issue.
>>
>> telnet www.encryptedserver2.com 80
>> Trying 216.74.27.203...
>> Connected to www.encryptedserver2.com.
>> Escape character is '^]'.
>> POST /alturawebservice/storewebservice.asmx HTTP/1.1
>> Host: www.encryptedserver2.com
>> Connection: close
>> Content-Type: text/xml; charset=utf-8
>> Content-length: 652
>> SOAPAction: https://www.encryptedserver2.com/alturawebservice/

>> ProductDetailV1
>>
>> > 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">> ENV:Header>>  xmlns="https://www.encryptedserver2.com/

>> alturawebservice/">1uuuu> Username>ppppaaaa> AccessPwd>1000> ProductDetailRequest>> ENV:Envelope>
>>>
>>
>>
>> The response from server is like this.  When I supplied a correct  
>> pair
>> of id/pw(which I can't disclose here) the server returned the product
>> information.
>>
>> 
>> http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>   
>>     
>>       soap:Client
>>       Fault occurred
>>       
>>         1001
>>         Invalid login
>>       
>>     
>>   
>> 
>>
>> Thanks..
>>
>> Kenji Noguchi
>>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Pywebsvcs-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk
> Also archived at http://groups.google.com/group/pywebsvcs

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Pywebsvcs-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk
Also archived at http://groups.google.com/group/pywebsvcs
 
CD: 3ms