http://iffm.me/clientes-soap-en-python.html https://gitter.im/msolorzano/sunat2015/archives/2015/10/31 https://stackoverflow.com/questions/28239100/suds-error-trying-to-load-wsdl https://pythonexample.com/code/python%20sunat%20suds%20example/ https://medium.com/@djperalta/python-suds-sunat-example-afc6c37ad426 http://www.codegist.net/code/python%20sunat%20suds%20example/
Last active
October 23, 2018 03:18
-
-
Save umiphos/a35425670b43e722ed48ca99762c2fa2 to your computer and use it in GitHub Desktop.
suds and sunat for peru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from suds.client import Client | |
from suds.wsse import * | |
import requests | |
import base64 | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logging.getLogger('suds.client').setLevel(logging.DEBUG) | |
#logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) | |
#logging.getLogger('suds.wsse').setLevel(logging.DEBUG) | |
def addSecurityHeader(client, username, password): | |
security = Security() | |
userNameToken = UsernameToken(username, password) | |
timeStampToken = Timestamp(validity=600) | |
security.tokens.append(userNameToken) | |
security.tokens.append(timeStampToken) | |
client.set_options(wsse=security) | |
username = 'MODDATOS' | |
password = 'MODDATOS' | |
session = requests.session() | |
session.auth = (username, password) | |
WSDL_URL = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl' | |
client = Client(WSDL_URL, faults=False, cachingpolicy=1, location=WSDL_URL) | |
addSecurityHeader(client, username, password) | |
fileName = "" | |
fileContent = "This is the base64 file" | |
import pdb;pdb.set_trace() | |
get_file = client.service.sendBill(fileName, fileContent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from suds import client | |
from suds.wsse import Security, UsernameToken as usernameToken | |
from suds.sudsobject import asdict | |
from suds import WebFault | |
username = 'MODDATOS' | |
password = 'MODDATOS' | |
wsdl_url = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl' | |
client = client.Client(wsdl_url) | |
security = Security() | |
token = usernameToken(username, password) | |
security.tokens.append(token) | |
client.set_options(wsse=security) | |
xml = open('xxxxxxxxxxx-01-FE01-00000001.zip') | |
result = client.service.sendBill("xxxxxxxxxxx-01-FE01-00000001.zip", xml.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from suds import client | |
from suds.wsse import Security, UsernameToken as usernameToken | |
from suds.sax.text import Raw | |
from suds.sudsobject import asdict | |
from suds import WebFault | |
username = '' | |
password = '' | |
wsdl_url = '' | |
client = client.Client(wsdl_url) | |
security = Security() | |
token = usernameToken(username, password) | |
security.tokens.append(token) | |
contentFile = '' | |
client.set_options(wsse=security) | |
import pdb;pdb.set_trace() | |
result = client.service.sendBill(fileName, contentFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment