Skip to content

Commit

Permalink
modify soap documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
shyal committed Dec 8, 2016
1 parent 3b5b325 commit 052de3c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
18 changes: 18 additions & 0 deletions docs/source/modify_soap.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. modify_soap
===========
modify soap
===========

In this example we'll take a look at using hoverpy in conjunction with middleware to modify SOAP data. This example builds upon the previous SOAP example, so I strongly suggest you do that one first.

.. literalinclude:: ../../examples/soap/soapModify.py
:language: python

and here is our payload modification script:

.. literalinclude:: ../../examples/soap/modify_payload.py
:language: python



2 changes: 1 addition & 1 deletion docs/source/readthedocs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a slightly more advanced example, where we query readthedocs.io for arti

the program can then be run again in simulate mode, in a fraction of the time:

`python examples/readthedocs/readthedocs.py``
``python examples/readthedocs/readthedocs.py``

We'll now run through the code to see what it's doing.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/soap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
soap
====

In this example we'll take a look a using hoverpy when working with SOAP. To run this example, simply execute:
In this example we'll take a look at using hoverpy when working with SOAP. To run this example, simply execute:

``examples/soap/soap.py --capture``

Expand Down
1 change: 1 addition & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ I don't know about you, but for me the best way of getting into things is by try
urllib2eg
urllib3eg
soap
modify_soap



29 changes: 8 additions & 21 deletions examples/soap/modify_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import json
import logging
import random
import traceback
from lxml import objectify
from lxml import etree


logging.basicConfig(filename='middleware.log', level=logging.DEBUG)
logging.debug('Middleware "modify_request" called')

Expand All @@ -24,32 +22,21 @@ def main():
root = objectify.fromstring(str(body))
ns = "{http://ws.cdyne.com/}"
logging.debug("transforming")
root.Body[
ns +
"ResolveIPResponse"][
ns +
"ResolveIPResult"].City = "New York"

objectify.deannotate(
root.Body[
ns +
"ResolveIPResponse"][
ns +
"ResolveIPResult"].City)
etree.cleanup_namespaces(
root.Body[
ns +
"ResolveIPResponse"][
ns +
"ResolveIPResult"].City)

ipe = ns + "ResolveIPResponse"
ipt = ns + "ResolveIPResult"

root.Body[ipe][ipt].City = "New York"

objectify.deannotate(root.Body[ipe][ipt].City)
etree.cleanup_namespaces(root.Body[ipe][ipt].City)

payload_dict["response"]["body"] = etree.tostring(root)

logging.debug(etree.tostring(root))

except Exception:
pass
# logging.debug(traceback.format_exc())

print(json.dumps(payload_dict))

Expand Down

0 comments on commit 052de3c

Please sign in to comment.