Найти - Пользователи
Полная версия: SOAPpy как это делается
Начало » Network » SOAPpy как это делается
1 2
S-10
Есть вот такая информация к размышлению
http://dpaste.com/772952/
Как такое отправляют с помощью питона?
agalen
Я для soap использую модуль suds. Ему даешь URL c WSDL, а дальше можно просто вызывать методы.
Пример:
client = suds.client.Client( "http://server/service.wsdl" )
res = client.service.MySuperPuperSoapRequest( arg1, arg2, arg3 )
S-10
agalen
я сделал вот так:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import suds

url = 'http://1.1.1.1/RSNetGain/RicoServer/InventorySoap.asmx'
client = suds.client.Client( url + ‘?WSDL’ )

def MySuperPuperSoapRequest( arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15 ):
text = “”“
<?xml version=”1.0“ encoding=”utf-8“?>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“ xmlns:xsd=”http://www.w3.org/2001/XMLSchema
xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/“>
<soap:Body>
<CheckAvailability xmlns=”http://ukrtelecom.net/webservices/Integration/BillingInventory“>
<requests>
<AvailabilityRequest>
<departmentId>%d</departmentId>
<address>
<settlementType>%d</settlementType>
<settlementTypeName>%s</settlementTypeName>
<settlementId>%d</settlementId>
<settlementName>%s</settlementName>
<streetType>%d</streetType>
<streetTypeName>%s</streetTypeName>
<streetName>%s</streetName>
<buildingNo>%s</buildingNo>
<auxilaryNo>%s</auxilaryNo>
<apartmentNo>%s</apartmentNo>
<auxilaryInfo>%s</auxilaryInfo>
</address>
</AvailabilityRequest>
</requests>
<connectionType>%d</connectionType>
<equipmentType>%d</equipmentType>
<activityType>%d</activityType>
</CheckAvailability>
</soap:Body>
</soap:Envelope>
”“” % ( arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15 )
return text

res = client.service.MySuperPuperSoapRequest( 0,2,'город',0,'Благовещенск',1,'Улица','пер.Чудиновский','50','','13','',0,0,1 )
print res

и получаю ошибку что метода MySuperPuperSoapRequest не существует
как сделать правильно?
odnochlen
S-10
как сделать правильно?
Правильно - использовать тег code, благо одменестрацыя соблагоизволила добавить панель бебекодов.
S-10
odnochlen
А по сабжу, конечно же, ты ничего не можешь сказать

odnochlen
Чтобы сказать - надо прочитать твой пост, а его читать не очень приятно.
S-10
Тут кода как такового пару строк, остальное xml, так что не надо мазаться что читать не удобно.
От тебя 0 пользы.
S-10
Для особо “одарённых” привожу код в тегах, хотя это не поможет наполнить голову знаниями
#! /usr/bin/env python                     
# -*- coding: utf-8 -*-                    
import suds
url = 'http://1.1.1.1/RSNetGain/RicoServer/InventorySoap.asmx'
client = suds.client.Client( url + '?WSDL' )
def MySuperPuperSoapRequest( arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15 ):
    text = """
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <CheckAvailability xmlns="http://ukrtelecom.net/webservices/Integration/BillingInventory">
      <requests>
        <AvailabilityRequest>
          <departmentId>%d</departmentId>
          <address>
            <settlementType>%d</settlementType>
            <settlementTypeName>%s</settlementTypeName>
            <settlementId>%d</settlementId>
            <settlementName>%s</settlementName>
            <streetType>%d</streetType>
            <streetTypeName>%s</streetTypeName>
            <streetName>%s</streetName>
            <buildingNo>%s</buildingNo>
            <auxilaryNo>%s</auxilaryNo>
            <apartmentNo>%s</apartmentNo>
            <auxilaryInfo>%s</auxilaryInfo>
          </address>
        </AvailabilityRequest>
      </requests>
      <connectionType>%d</connectionType>
      <equipmentType>%d</equipmentType>
      <activityType>%d</activityType>
    </CheckAvailability>
  </soap:Body>
</soap:Envelope>
""" % ( arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15 )
    return text
res = client.service.MySuperPuperSoapRequest( 0,2,'город',0,'Благовещенск',1,'Улица','пер.Чудиновский','50','','13','',0,0,1 )
print res
odnochlen
S-10
Для особо “одарённых”
Правила прочти, “одаренный”.
S-10
odnochlen
Отстань, противный.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB