当前位置: 首页>>代码示例>>Python>>正文


Python SoapClient.http方法代码示例

本文整理汇总了Python中pysimplesoap.client.SoapClient.http方法的典型用法代码示例。如果您正苦于以下问题:Python SoapClient.http方法的具体用法?Python SoapClient.http怎么用?Python SoapClient.http使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysimplesoap.client.SoapClient的用法示例。


在下文中一共展示了SoapClient.http方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_wsfexv1_getcmp

# 需要导入模块: from pysimplesoap.client import SoapClient [as 别名]
# 或者: from pysimplesoap.client.SoapClient import http [as 别名]
 def test_wsfexv1_getcmp(self):
     """Test Argentina AFIP Electronic Invoice WSFEXv1 GetCMP method"""
     # create the proxy and parse the WSDL
     client = SoapClient(
         wsdl="https://wswhomo.afip.gov.ar/wsfexv1/service.asmx?WSDL",
         cache=None
     )
     # load saved xml
     xml = open(os.path.join(TEST_DIR, "wsfexv1_getcmp.xml")).read()
     client.http = DummyHTTP(xml)
     # call RPC
     ret = client.FEXGetCMP(
         Auth={'Token': "", 'Sign': "", 'Cuit': "0"},
         Cmp={
             'Cbte_tipo': "19",
             'Punto_vta': "3",
             'Cbte_nro': "38",
         })
     # analyze result
     result = ret['FEXGetCMPResult']
     self.assertEqual(result['FEXErr']['ErrCode'], 0)
     self.assertEqual(result['FEXErr']['ErrMsg'], 'OK')
     self.assertEqual(result['FEXEvents']['EventCode'], 0)
     resultget = result['FEXResultGet']
     self.assertEqual(resultget['Obs'], None)
     self.assertEqual(resultget['Cae'], '61473001385110')
     self.assertEqual(resultget['Fch_venc_Cae'], '20111202')
     self.assertEqual(resultget['Fecha_cbte'], '20111122')
     self.assertEqual(resultget['Punto_vta'], 3)
     self.assertEqual(resultget['Resultado'], "A")
     self.assertEqual(resultget['Cbte_nro'], 38)
     self.assertEqual(resultget['Imp_total'], Decimal('130.21'))
     self.assertEqual(resultget['Cbte_tipo'], 19)
开发者ID:adammendoza,项目名称:pysimplesoap,代码行数:35,代码来源:afip_test.py

示例2: test_buscar_personas_raw

# 需要导入模块: from pysimplesoap.client import SoapClient [as 别名]
# 或者: from pysimplesoap.client.SoapClient import http [as 别名]
    def test_buscar_personas_raw(self):

        url = "http://www.testgobi.dpi.sfnet/licencias/web/soap.php"
        client = SoapClient(location=url, ns="web",
                            namespace="http://wwwdesagobi.dpi.sfnet:8080/licencias/web/",
                            action=url)
        # load dummy response (for testing)
        client.http = DummyHTTP(self.xml)
        client['AuthHeaderElement'] = {'username': 'mariano', 'password': 'clave'}
        response = client.PersonaSearch(persona=(('numero_documento', '99999999'),
                                                 ('apellido_paterno', ''),
                                                 ('apellido_materno', ''),
                                                 ('nombres', ''),
                                                 ))

        # the raw response is a SimpleXmlElement object:

        self.assertEqual(str(response.result.item[0]("xsd:string")[0]), "resultado")
        self.assertEqual(str(response.result.item[0]("xsd:string")[1]), "true")
        self.assertEqual(str(response.result.item[1]("xsd:string")[0]), "codigo")
        self.assertEqual(str(response.result.item[1]("xsd:string")[1]), "WS01-01")
        self.assertEqual(str(response.result.item[2]("xsd:string")[0]), "mensaje")
        self.assertEqual(str(response.result.item[2]("xsd:string")[1]), "Se encontraron 1 personas.")
        self.assertEqual(str(response.result.item[2]("xsd:string")[0]), "mensaje")
        self.assertEqual(str(response.result.item[2]("xsd:string")[1]), "Se encontraron 1 personas.")

        self.assertEqual(str(response.result.item[3]("xsd:anyType")[0]), "datos")
        self.assertEqual(str(response.result.item[3]("xsd:anyType")[1]("ns2:Map").item[0].key), "lic_ps_ext_id")
        self.assertEqual(str(response.result.item[3]("xsd:anyType")[1]("ns2:Map").item[0].value), "123456")
        self.assertEqual(str(response.result.item[3]("xsd:anyType")[1]("ns2:Map").item[10].key), "fecha_nacimiento")
        self.assertEqual(str(response.result.item[3]("xsd:anyType")[1]("ns2:Map").item[10].value), "1985-10-02 00:00:00")
开发者ID:AmineCherrai,项目名称:pysimplesoap,代码行数:33,代码来源:licencias_test.py

示例3: test_buscar_personas_wsdl

# 需要导入模块: from pysimplesoap.client import SoapClient [as 别名]
# 或者: from pysimplesoap.client.SoapClient import http [as 别名]
    def test_buscar_personas_wsdl(self):
        WSDL = "file://" + os.path.join(TEST_DIR, "licencias.wsdl")
        client = SoapClient(wsdl=WSDL, ns="web")
        print(client.help("PersonaSearch"))
        client['AuthHeaderElement'] = {'username': 'mariano', 'password': 'clave'}
        client.http = DummyHTTP(self.xml)
        resultado = client.PersonaSearch(numero_documento='31867063')
        print(resultado)

        # each resultado['result'][i]['item'] is xsd:anyType, so it is not unmarshalled
        # they are SimpleXmlElement (see test_buscar_personas_raw)
        self.assertEqual(str(resultado['result'][0]['item']('xsd:string')[0]), "resultado")
        self.assertEqual(str(resultado['result'][1]['item']('xsd:string')[1]), "WS01-01")
        self.assertEqual(str(resultado['result'][3]['item']('xsd:anyType')[1]("ns2:Map").item[10].value), "1985-10-02 00:00:00")
开发者ID:AmineCherrai,项目名称:pysimplesoap,代码行数:16,代码来源:licencias_test.py

示例4: test_buscar_personas_wsdl

# 需要导入模块: from pysimplesoap.client import SoapClient [as 别名]
# 或者: from pysimplesoap.client.SoapClient import http [as 别名]
    def test_buscar_personas_wsdl(self):
        WSDL = "file://" + os.path.join(TEST_DIR, "licencias.wsdl")
        client = SoapClient(wsdl=WSDL, ns="web", trace=True)
        print client.help("PersonaSearch")
        client["AuthHeaderElement"] = {"username": "mariano", "password": "clave"}
        client.http = DummyHTTP(self.xml)
        resultado = client.PersonaSearch(numero_documento="31867063")
        print resultado

        # each resultado['result'][i]['item'] is xsd:anyType, so it is not unmarshalled
        # they are SimpleXmlElement (see test_buscar_personas_raw)
        self.assertEqual(str(resultado["result"][0]["item"]("xsd:string")[0]), "resultado")
        self.assertEqual(str(resultado["result"][1]["item"]("xsd:string")[1]), "WS01-01")
        self.assertEqual(
            str(resultado["result"][3]["item"]("xsd:anyType")[1]("ns2:Map").item[10].value), "1985-10-02 00:00:00"
        )
开发者ID:rcarmo,项目名称:pysimplesoap,代码行数:18,代码来源:licencias_tests.py

示例5: test_issue93

# 需要导入模块: from pysimplesoap.client import SoapClient [as 别名]
# 或者: from pysimplesoap.client.SoapClient import http [as 别名]
    def test_issue93(self):
        """Response with <xs:schema> and <xs:any>"""
        # attached sample response to the ticket:
        xml = """
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.
xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap
.org/ws/2004/08/addressing"><soap:Header><wsa:Action>http://smbsaas/websitepanel
/enterpriseserver/AddPackageResponse</wsa:Action><wsa:MessageID>urn:uuid:af841fc
e-4607-4e4b-910e-252d1f1857fb</wsa:MessageID><wsa:RelatesTo>urn:uuid:fea15079-42
57-424b-8da7-8c9a29ec52ce</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2
004/08/addressing/role/anonymous</wsa:To></soap:Header><soap:Body><AddPackageRes
ponse xmlns="http://smbsaas/websitepanel/enterpriseserver"><AddPackageResult><Re
sult>798</Result><ExceedingQuotas><xs:schema id="NewDataSet" xmlns="" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-ms
data"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLoc
ale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:el
ement name="Table"><xs:complexType><xs:sequence><xs:element name="QuotaID" type=
"xs:int" minOccurs="0" /><xs:element name="QuotaName" type="xs:string" minOccurs
="0" /><xs:element name="QuotaValue" type="xs:int" minOccurs="0" /></xs:sequence
></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:sc
hema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:
diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" /></ExceedingQuotas></AddPack
ageResult></AddPackageResponse></soap:Body></soap:Envelope>
"""
        xml = xml.replace("\n","").replace("\r","")
        # parse the wsdl attached to the ticket
        client = SoapClient(wsdl="https://pysimplesoap.googlecode.com/issues/attachment?aid=930004001&name=wsdl.txt&token=MIcIgTXvGmzpfFgLM-noYLehzwU%3A1399083528469", trace=False)        
        # put the sample response (no call to the real webservice is made...)
        client.http = DummyHTTP(xml)
        result = client.AddPackage(657, 33, 'Services', 'Comment', 1, datetime.datetime.now())
        # check unmarshalled results:
        self.assertEquals(result['AddPackageResult']['Result'], 798)
        # the schema is also returned as a SimpleXMLElement object (unmarshalled), get the xml:
        self.assertEquals(repr(result['AddPackageResult']['ExceedingQuotas']['schema']['element']),
            '<xs:element msdata:IsDataSet="true" msdata:UseCurrentLocale="true" name="NewDataSet"><xs:complexType><xs:choice maxOccurs="unbounded" minOccurs="0"><xs:element name="Table"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="QuotaID" type="xs:int"/><xs:element minOccurs="0" name="QuotaName" type="xs:string"/><xs:element minOccurs="0" name="QuotaValue" type="xs:int"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element>')
        # the any is also returned as a SimpleXMLElement object (unmarshalled)
        self.assertEquals(str(result['AddPackageResult']['ExceedingQuotas']['diffgram']), '')
开发者ID:smartylab,项目名称:pysimplesoap,代码行数:40,代码来源:issues_test.py


注:本文中的pysimplesoap.client.SoapClient.http方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。