I've already defined the v2 ns and namespace in my SoapClient() initialization, why would I want/need to define it again?
client = SoapClient(location=soapLocation,action=soapAction,namespace=namespaceValue,ns=nsValue,trace=True,http_headers=httpHeaders) GetOrders gets the v2 ns applied to it automatically, is there a way to have that happen to all elements in SimpleXMLElement automatically? Thanks. -Tim On Mon, Apr 27, 2015 at 10:13 PM, Mariano Reingart <[email protected]> wrote: > You'll need to specify the namespace URI so the python parser can detect > it (in the same node or in the xml root): > > bd = SimpleXMLElement("""<v2:BusinessDate > xmlns:v2="%s">2015-04-24T00:00:00</v2:BusinessDate>""" % namespaceValue, > ) > > Regards > > Mariano Reingart > http://www.sistemasagiles.com.ar > http://reingart.blogspot.com > > On Mon, Apr 27, 2015 at 9:48 PM, Tim Callaghan <[email protected]> > wrote: > >> That worked, so now I'm close. >> >> However, I need a little more for this, >> "<v2:request><v2:BusinessDate>2015-04-24T00:00:00</v2:BusinessDate></v2:request>". >> I can easily add the "request" tags, but if I ask for a "v2:" prefix it >> gives me parsing errors. >> >> I got the syntax from here, >> https://code.google.com/p/pysimplesoap/wiki/SoapClient#Basic_example_not_using_WSDL >> >> On Mon, Apr 27, 2015 at 6:22 PM, Mariano Reingart <[email protected]> >> wrote: >> >>> On Mon, Apr 27, 2015 at 6:22 PM, Tim Callaghan <[email protected]> >>> wrote: >>> >>>> Here's my code. When I "print bd.as_xml()" it looks good to me, but all >>>> that ends up in my <v2:response> is 2015-04-24T00:00:00, not >>>> <BusinessDate> >>>> 2015-04-24T00:00:00</BusinessDate>. Help. -Tim >>>> >>>> >>>> -------- BEGIN CODE -------------- >>>> >>>> from pysimplesoap.client import SoapClient >>>> from pysimplesoap.simplexml import SimpleXMLElement >>>> >>>> soapLocation="https://www.changed-for-example.com/Sales2.svc >>>> <https://api5.brinkpos.net/Sales2.svc>" >>>> soapAction=" >>>> http://www.changed-for-example.com/webservices/sales/v2/ISalesWebService2/ >>>> <http://www.brinksoftware.com/webservices/sales/v2/ISalesWebService2/>" >>>> nsValue="v2" >>>> namespaceValue="http://www.changed-for-example.com/webservices/sales/v2 >>>> <http://www.brinksoftware.com/webservices/sales/v2>" >>>> httpHeaders = {'AccessToken':'**NOT*THE*REAL*TOKEN', 'LocationToken':' >>>> **NOT*THE*REAL*TOKEN'} >>>> >>>> client = >>>> SoapClient(location=soapLocation,action=soapAction,namespace=namespaceValue,ns=nsValue,trace=True,http_headers=httpHeaders) >>>> >>>> bd = >>>> SimpleXMLElement("<BusinessDate>2015-04-24T00:00:00</BusinessDate>") >>>> >>>> response = client.GetOrders(request=bd) >>>> >>>> >>>> >>> Can you test the following code instead calling client.getOrders >>> directly? >>> >>> response = client.call("GetOrders", bd) >>> >>> That will detect bd as a raw simple xml object to be serialized. >>> That generates the following output (with BusinessDate included): >>> >>> INFO:pysimplesoap.client:POST >>> https://www.changed-for-example.com/Sales2.svc >>> DEBUG:pysimplesoap.client:SOAPAction: " >>> http://www.changed-for-example.com/webservices/sales/v2/ISalesWebService2/GetOrders >>> " >>> Content-length: 296 >>> Content-type: text/xml; charset="UTF-8" >>> AccessToken: **NOT*THE*REAL*TOKEN >>> LocationToken: **NOT*THE*REAL*TOKEN >>> DEBUG:pysimplesoap.client:<?xml version="1.0" >>> encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv=" >>> http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2=" >>> http://www.changed-for-example.com/webservices/sales/v2"> >>> <soapenv:Header/> >>> >>> <soapenv:Body><BusinessDate>2015-04-24T00:00:00</BusinessDate></soapenv:Body></soapenv:Envelope> >>> >>> BTW, from where did you get the response=raw syntax? >>> >>> Best regards, >>> >>> Mariano Reingart >>> http://www.sistemasagiles.com.ar >>> http://reingart.blogspot.com >>> >>> >>> >> >
_______________________________________________ Soap mailing list [email protected] https://mail.python.org/mailman/listinfo/soap
