[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

sending a handmade SOAP request

Bernard

1/31/2008 7:03:00 PM

Hey y'all,

Is there a way to POST a handmade SOAP request *without* using any
libraries like SOAPpy? I've been having some communication trouble
with a server using the new wse3 (http://www.microsoft.com/...
details.aspx?
familyid=018A09FD-3A74-43C5-8EC1-8D789091255D&displaylang=en).

they keep on sending back this strange error :
SOAPpy.Types.faultType: <Fault q0:Security: Header
http://schemas.xmlsoap.org/ws/2004/08/address... for ultimate
recipient is required but not present in the message.>

We've tried using SOAPui (http://sourceforge.net/projec...) as
well to test the web service out. this little baby builds a proper
SOAP request based on the wsdl file. we keep on hitting that error
again & again...

so what is up with that?
4 Answers

Van Gale

1/31/2008 8:24:00 PM

0

On Thu, 31 Jan 2008 11:03:26 -0800, Bernard wrote:

> Hey y'all,
>
> Is there a way to POST a handmade SOAP request *without* using any
> libraries like SOAPpy?

Yes, it's quite easy to SOAP by hand.

I use Oren Tirosh's ElementBuilder class (on top of lxml instead of
ElementTree) to build the SOAP request and the xpath capabilities in lxml
to pull out the data I need from the response.

http://www.tothink.com/python/Eleme...
http://codespeak...

An incomplete example for contructing a request looks something like this:

body = Element('soap:Envelope',
{ 'xmlns:soap': nss['soap']},
Element('soap:Header'), Element('soap:Body',
{ 'xmlns:msgs': nss['msgs'] },
Element('msgs:login',
Element('msgs:passport',
{ 'xmlns:core': nss['core'] },
Element('core:password', password),
Element('core:account', account)))))

I use httplib2 for sending the HTTP requests:

http://code.google.com/p...

Incomplete example:

headers['SOAPAction'] = action
headers['Content-length'] = str(len(etree.tostring(body)))
response, content = self._client.request(
self.ns_uri, "POST",
body=etree.tostring(body), headers=self._headers)
if response.status == 500 and not (response["content-type"].startswith("text/xml") and len(content) > 0):
raise HTTPError(response.status, content)
if response.status not in (200, 500):
raise HTTPError(response.status, content)
doc = etree.parse(StringIO(content))
if response.status == 500:
faultstring = doc.findtext(".//faultstring")
raise HTTPError(response.status, faultstring)

Now it's just a matter of using xpath expressions to dig into the "doc"
structure for the bits you need.

Stefan Behnel

1/31/2008 8:52:00 PM

0

Hi,

Bernard wrote:
> Is there a way to POST a handmade SOAP request *without* using any
> libraries like SOAPpy?

This might help:

http://effbot.org/zone/elemen...

I didn't try, but it should also work with lxml - which might make a couple of
things a little easier, as it gives you XPath and (a lot of its) friends. For
request generation, this little feature might also be of interest:

http://codespeak.net/lxml/dev/tutorial.html#the...

Stefan

Bernard

1/31/2008 9:00:00 PM

0

On 31 jan, 15:23, Van Gale <vang...@gmail.com> wrote:
> Yes, it's quite easy to SOAP by hand.
>
> I use Oren Tirosh's ElementBuilder class (on top of lxml instead of
> ElementTree) to build the SOAP request and the xpath capabilities in lxml
> to pull out the data I need from the response.
>
> http://www.tothink.com/python/ElementBuilder/http://codespeak...
>
> An incomplete example for contructing a request looks something like this:
>
> body = Element('soap:Envelope',
> { 'xmlns:soap': nss['soap']},
> Element('soap:Header'), Element('soap:Body',
> { 'xmlns:msgs': nss['msgs'] },
> Element('msgs:login',
> Element('msgs:passport',
> { 'xmlns:core': nss['core'] },
> Element('core:password', password),
> Element('core:account', account)))))
>
> I use httplib2 for sending the HTTP requests:
>
> http://code.google.com/p...
>
> Incomplete example:
>
> headers['SOAPAction'] = action
> headers['Content-length'] = str(len(etree.tostring(body)))
> response, content = self._client.request(
> self.ns_uri, "POST",
> body=etree.tostring(body), headers=self._headers)
> if response.status == 500 and not > (response["content-type"].startswith("text/xml") and > len(content) > 0):
> raise HTTPError(response.status, content)
> if response.status not in (200, 500):
> raise HTTPError(response.status, content)
> doc = etree.parse(StringIO(content))
> if response.status == 500:
> faultstring = doc.findtext(".//faultstring")
> raise HTTPError(response.status, faultstring)
>
> Now it's just a matter of using xpath expressions to dig into the "doc"
> structure for the bits you need.

oh my that is quite the handy answer Van Gal! I'll try it out right
now. thanks a bunch man!

Matt

12/17/2012 8:44:00 PM

0

MattB <trdell1234@gmail.com> wrote in
news:jr0vc81fjm1kkqk4fs9n2i2r54gsvv7t3o@4ax.com:

> On Mon, 17 Dec 2012 08:14:28 +0000 (UTC), Matt
> <matttelles@sprynet.com> wrote:
>
>>MattB <trdell1234@gmail.com> wrote in
>>news:pf5tc8h11t1gm74l9vubi15tiesle4c1kd@4ax.com:
>>
>>> On Mon, 17 Dec 2012 02:46:44 +0000 (UTC), Matt
>>> <matttelles@sprynet.com> wrote:
>>>
>>>>MattB <trdell1234@gmail.com> wrote in
>>>>news:51msc89rgdmtjj4c89jbj6ckhsv8m1uae7@4ax.com:
>>>>
>>>>> On Sun, 16 Dec 2012 23:00:42 +0000 (UTC), Matt
>>>>> <matttelles@sprynet.com> wrote:
>>>>>
>>>>>>MattB <trdell1234@gmail.com> wrote in
>>>>>>news:i2jsc8l107q3d8dvsd9a7p8sr3mpoqdb34@4ax.com:
>>>>>>
>>>>>>> On Sun, 16 Dec 2012 22:20:21 +0000 (UTC), Matt
>>>>>>> <matttelles@sprynet.com> wrote:
>>>>>>>
>>>>>>>>MattB <trdell1234@gmail.com> wrote in
>>>>>>>>news:7jhsc8tk4tqqb5ucuk6p9hki7kihoagae6@4ax.com:
>>>>>>>>
>>>>>>>>> On Sun, 16 Dec 2012 21:49:30 +0000 (UTC), Matt
>>>>>>>>> <matttelles@sprynet.com> wrote:
>>>>>>>>>
>>>>>>>>>>MattB <trdell1234@gmail.com> wrote in
>>>>>>>>>>news:1pgsc8d97p4sl3efkc7jgg1bo1u6eseh3n@4ax.com:
>>>>>>>>>>
>>>>>>>>>>> On Sun, 16 Dec 2012 21:13:14 +0000 (UTC), Matt
>>>>>>>>>>> <matttelles@sprynet.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>MattB <trdell1234@gmail.com> wrote in
>>>>>>>>>>>>news:lpesc8l69ph8aoespi8fit86l7nmq5748i@4ax.com:
>>>>>>>>>>>>
>>>>>>>>>>>>> Connecticut shooting ranges up and running as gun control
>>>>debate
>>>>>>>>>>rages
>>>>>>>>>>>>>
>>>>>>>>>>>>> http://www.guardian.co.uk/world/2012/dec/1...
>>shooting-
>>>>>>>>ranges-
>>>>>>>>>>>>gun
>>>>>>>>>>>>> -control
>>>>>>>>>>>>>
>>>>>>>>>>>>> At the Shooters pistol range in New Milford, Connecticut,
it
>>>>was
>>>>>>>>>>>>> business as usual. A steady turnover of customers passed
>>>>through
>>>>>>>>the
>>>>>>>>>>>>> half-full parking lot and the "pop, pop" of guns being
fired
>>>>>>>>inside
>>>>>>>>>>>>> could be heard roughly every 10 seconds.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Just 48 hours after America's deadliest primary school
>>>>shooting,
>>>>>>>>the
>>>>>>>>>>>>> message was clear: it will take more than a grotesque gun
>>>>>>rampage
>>>>>>>>>>>>> through a class of six-year-olds to detach America from
its
>>>>>>fierce
>>>>>>>>>>>>> affinity for firearms.
>>>>>>>>>>>>>
>>>>>>>>>>>>> While local people offered prayers in church and Barack
>>Obama
>>>>>>>>headed
>>>>>>>>>>>>> into Newtown to join the community mourning for the 20
>>>>children
>>>>>>>>and
>>>>>>>>>>>>> six teachers killed on Friday, Shooters was doing brisk
>>>>>>business.
>>>>>>>>>>The
>>>>>>>>>>>>> manager of the range would not say a word to the Guardian,
>>but
>>>>>>he
>>>>>>>>>>did
>>>>>>>>>>>>> confirm by nodding his head that the range was open.
>>>>Outwardly,
>>>>>>it
>>>>>>>>>>>>> appeared as if nothing had changed.
>>>>>>>>>>>>>
>>>>>>>>>>>>> But at least one customer signalled that America's gun
lobby
>>>>>>might
>>>>>>>>>>be
>>>>>>>>>>>>> on the cusp of a moment of introspection. Mike D'Amico had
>>>>come
>>>>>>to
>>>>>>>>>>the
>>>>>>>>>>>>> range on Sunday morning accompanied by his 14-year-old
son.
>>It
>>>>>>was
>>>>>>>>>>>>> their regular treat, an hour of target practice. "We enjoy
>>it,
>>>>>>>>it's
>>>>>>>>>>>>> our personal enjoyment," he said.
>>>>>>>>>>>>>
>>>>>>>>>>>>> When asked what he thought of President Obama's call for
>>>>>>>>"meaningful
>>>>>>>>>>>>> action" on gun control, and the rising chorus that enough
>>was
>>>>>>>>>>enough,
>>>>>>>>>>>>> D'Amico gave a surprising answer: "I've thought this for
>>quite
>>>>a
>>>>>>>>>>>>> while," he said. "I think we do need more gun control. I
>>don't
>>>>>>see
>>>>>>>>>>the
>>>>>>>>>>>>> need people to carry some of these big guns. They're not
>>>>>>>>>>appropriate."
>>>>>>>>>>>>>
>>>>>>>>>>>>> It is not known whether the Sandy Hook shooter, Adam
Lanza,
>>>>ever
>>>>>>>>>>>>> frequented Shooters, though the range is one of the
closest
>>to
>>>>>>the
>>>>>>>>>>>>> house in which he lived in Newtown. What is known is that
>>>>>>Lanza's
>>>>>>>>>>>>> mother, Nancy, whom he killed before setting off to the
>>>>>>elementary
>>>>>>>>>>>>> school, was very keen on guns.
>>>>>>>>>>>>>
>>>>>>>>>>>>> She had at least four weapons in the large rambling house
>>she
>>>>>>>>shared
>>>>>>>>>>>>> with her son ? guns that he turned on her and then used to
>>end
>>>>>>the
>>>>>>>>>>>>> lives of 26 people at the school including the 20 six- and
>>>>>>>>>>>>> seven-year-old children. Nancy Lanza is understood to have
>>>>taken
>>>>>>>>him
>>>>>>>>>>>>> with her on target practice outings at shooting ranges.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Shooters has 12 stations where customers can hit targets
at
>>up
>>>>>>to
>>>>>>>>50
>>>>>>>>>>>>> feet. The range rents out to users who lack their own
>>weapons,
>>>>>>>>>>>>> advertising rentals of revolvers and semiautomatic
handguns
>>>>and
>>>>>>>>>>rifles
>>>>>>>>>>>>> from .22 to .45 calibers.
>>>>>>>>>>>>>
>>>>>>>>>>>>> According to Connecticut police, Adam Lanza took three
>>weapons
>>>>>>>>with
>>>>>>>>>>>>> him into the school: Glock and Sig Sauer semiautomatic
>>>>handguns
>>>>>>>>and
>>>>>>>>>>a
>>>>>>>>>>>>> Bushmaster semiautomatic rifle ? the latter being the
>>firearm
>>>>>>that
>>>>>>>>>>was
>>>>>>>>>>>>> used to most deadly effect.
>>>>>>>>>>>>>
>>>>>>>>>>>>> In Sandy Hook and the nearby town of Newtown, meanwhile,
the
>>>>>>local
>>>>>>>>>>>>> community was engaged in a very different sort of Sunday
>>>>>>tradition
>>>>>>>>>>to
>>>>>>>>>>>>> that of the weekly visit to the shooting range: they came
to
>>>>>>>>worship
>>>>>>>>>>>>> not the gun, but God ? though even that activity was
rudely
>>>>>>>>>>>>> interrupted at one church where a bomb hoax briefly
resulted
>>>>in
>>>>>>>>the
>>>>>>>>>>>>> evacuation of the congregation.
>>>>>>>>>>>>>
>>>>>>>>>>>>> At Trinity Episcopal church in Newtown, about a mile from
>>the
>>>>>>>>center
>>>>>>>>>>>>> of Sandy Hook, members of the clergy handed out a box of
>>>>tissues
>>>>>>>>for
>>>>>>>>>>>>> every pew ahead of the service.
>>>>>>>>>>>>>
>>>>>>>>>>>>> The rector, Kathleen Adams-Shepherd, told the congregation
>>>>that
>>>>>>>>she
>>>>>>>>>>>>> had been at the firehouse close to Sandy Hook elementary
>>>>waiting
>>>>>>>>and
>>>>>>>>>>>>> praying with families. She was there when some of those
>>>>families
>>>>>>>>>>found
>>>>>>>>>>>>> out their children would not be coming home.
>>>>>>>>>>>>>
>>>>>>>>>>>>> What happened that day was not God's will, Adams-Shepherd
>>told
>>>>>>the
>>>>>>>>>>>>> churchgoers. Some wept as a reading listed the names of
>>those
>>>>>>>>>>killed.
>>>>>>>>>>>>> Six-year-old Benjamin Wheeler, whose parents worshipped at
>>>>>>Trinity
>>>>>>>>>>>>> Episcopal, was among the dead.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Adams-Shepherd and the other members of the clergy came
down
>>>>>>among
>>>>>>>>>>the
>>>>>>>>>>>>> congregation, some of them squeezing into pews next to the
>>>>>>>>>>>>> congregation. "I wanted to be among you," the rector said.
>>She
>>>>>>>>>>>>> encouraged people to hug each other, prompting emotional
>>>>>>embraces.
>>>>>>>>>>>>>
>>>>>>>>>>>>> "Jesus will still come," Adams-Shepherd said. "Santa will
>>come
>>>>>>>>too,"
>>>>>>>>>>>>> she added.
>>>>>>>>>>>>>
>>>>>>>>>>>>> In her address to the church, she said she had made a
>>>>conscious
>>>>>>>>>>>>> decision not to allow television crews and photographers
>>into
>>>>>>the
>>>>>>>>>>>>> church during the last few days and during Sunday's
service.
>>>>>>>>>>Families
>>>>>>>>>>>>> of the victims should be left in private, Adams-Shepherd
>>said,
>>>>>>and
>>>>>>>>>>the
>>>>>>>>>>>>> church should be a place of respite.
>>>>>>>>>>>>>
>>>>>>>>>>>>> "Thank you pastor," one churchgoer called out. The
>>>>congregation
>>>>>>>>>>broke
>>>>>>>>>>>>> into a standing ovation.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Whether these two institutions in one small community ?
the
>>>>>>church
>>>>>>>>>>and
>>>>>>>>>>>>> the pistol range ? can find a common purpose in the
>>difficult
>>>>>>>>weeks
>>>>>>>>>>>>> and months ahead may determine the nature of Sandy Hook's,
>>and
>>>>>>>>>>>>> America's, response to this tragedy.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>Absolutely, gotta give them gun nuts practice. They might
miss
>>a
>>>>5
>>>>>>>>>>year
>>>>>>>>>>>>old next time.
>>>>>>>>>>>>
>>>>>>>>>>>>And you back them. Good for you.
>>>>>>>>>>>
>>>>>>>>>>> Matt you are the one the advocates murder on here.
>>>>>>>>>>
>>>>>>>>>>If you cannot understand the difference between you gun nuts
>>>>>>murdering
>>>>>>>>>>kids, and the country legally executing you, you need to
leave.
>>>>>>>>>
>>>>>>>>> LOL We don't have to leave and you are powerless to enforce
>>such
>>>>a
>>>>>>>>> stupid desire.
>>>>>>>>
>>>>>>>>Really.
>>>>>>>>
>>>>>>>>You seem to have a problem with the law, and gun nut criminals.
>>>>>>>
>>>>>>> Name the law in question I have a problem with? If a
Progressive
>>>>>>> proposed law what is it's wording??
>>>>>>
>>>>>>There are no "Progessive Laws". Only idiots believe that.
>>>>>>
>>>>>>The law in question is using a gun to kill someone.
>>>>>
>>>>> Other than in self defense? So what is your problem in reality?
>>I
>>>>> agree murder is murder no matter how it is done.
>>>>
>>>>Learning to read, and then comprehend, would help you a lot. Self-
>>>>defense has never been a crime, if you can prove you defended
>>yourself.
>>>>Claiming it is not proof.
>>>
>>> So again what is your point and what do you want done. Murder is a
>>> crime already for all. So again what is your point.
>>
>>My proof? My proof is called the 'law'. Try it some time.
>
> I asked for your point is you madness of promoting violence. Instead
> you dance.

What dance? Commit a crime while holding a gun, and you die.

Is that simple enough for you?

Matt