English 中文(简体)
Consume WSDL url 和XML 一起逃离果园
原标题:Consume WSDL url with XML with escaped chars as argument

I am executing a method of a SOAP web service which receives 3 string arguments with suds library.

第一个论点应当是XML,另一个是用户名和密码,这是我的半工作执行。

from suds.client import Client
url = "http://www.jonima.com.mx:3014/sefacturapac/TimbradoService?wsdl"
client = Client(url)
client.service.timbrado(XML_AS_STRING_HERE,  PRUEBA1 ,  12345678 )

When the first parameter contains an escaped character (ampersand, quotes, apostrophe, less than, bigger than) method does not work because the server interprets the text as if it were unescaped. If doesn t contain any of those chars the method works great

XML example without ampersand works http://dl.dropbox.com/u/1990697/no_amp.xml

XML example with ampersand doesn t work http://dl.dropbox.com/u/1990697/with_amp.xml

Any idea how can I pass XML with escaped chars?

It doesn t have to rely on suds but in python. I am using python 2.6 (How ever it could be with 2.7 if required)

我也利用了Django框架,不知道这是否有用。


Extra Info:

  • I have no access to modify SOAP server
  • Customer support told me my xml are correct and that they work for them, so the error is in my implementation (or somewhere in suds?)
最佳回答

I think the suds library is the culprit here. When you send your escaped xml into suds as a parameter to the client.service.timbrado method it also escapes it. However, it sees that you have escaped the ampersand already like this:

...
descripcion="EJE&MPLO"
...

而没有越狱(尽管应该如此)。 页: 1

This should result in xml snippet above looking like this:

...
descripcion="EJE&MPLO"
...

When I run your code with the doubly-escaped xml, I receive the following result:

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:timbradoResponse xmlns:ns2="http://sefactura.com">
            <return>
                <status>401 - Fecha y hora de generación fuera de rango</status>
            </return>
        </ns2:timbradoResponse>
    </S:Body>
</S:Envelope>

相对于Xml格式而言,这在你的数据(距离生成的日期和时间)上是一个错误。

问题回答

你们是否曾两度试图放弃他们?

如果这项服务中断,你应提交简短报告,并采取预防措施,以便你在固定服务时注意到这一报告,并取消你的工作。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签