tags:

views:

57

answers:

2

Hi, I am trying to send raw xml to a service in Python. I have a the address of the service and my question is how would I wrap XML in python and send it to the service. The address is in the format below.

192.1100.2.2:54239

And say the XML is:

<xml version="1.0" encoding="UTF-8"><header/><body><code><body/>

Anyone know what to do?

+3  A: 

This should do the trick.

import socket
import time

command = '<xml version="1.0" encoding="UTF-8"><header/><body><code><body/>'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.1100.2.2", 54239))

s.send(command)

time.sleep(2)
resp = s.recv(3000)

print resp
chrissygormley
A: 
pydoc socket

... should get you started.

PS. Your example IP address looks a bit strange (1100 is greater than 255), but maybe that's just so nobody tries to use it ...

Rasmus Kaj
IP address is indeed invalid.
anijhaw