Your SlideShare is downloading. ×
Ne legyünk REST-ek továbblépni, azaz SOAP web szolgáltatások
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Ne legyünk REST-ek továbblépni, azaz SOAP web szolgáltatások

580
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
580
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ne legyünk REST-ektovábblépni, azaz SOAP web szolgáltatások Szalai Ferenc (szferi@wsbricks.com)
  • 2. Mi a baj a REST-el?
  • 3. Mikor használjunk SOAP-ot?● Magas biztonság (WS-Sec, XMLSec, SAML)● Aszinkron szolgáltatás● Állapottartó szolgáltatás (WS-Addressing)● Ipari környezet, sokféle nem ismert kliens● Interface specifikació formálisan kell● Service felfedezés
  • 4. Problémák
  • 5. Típusos interfész vs.nem erősen típusos nyelv
  • 6. Python SOAP lib?● SOAPpy – nem standard, nehézkes tipus kezelés● ZSI – nem standard, túl körülményes típus kezelés● soaplib – névterek kezelésének hiánya
  • 7. decorator_with_args = lambda decorator: lambda *args,**kwargs: lambda func: decorator(func, *args, **kwargs)@decorator_with_argsdef soapmethod(func, *params, **kwparams): @functools.wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs) wrapper.__doc__ = func.__doc__ wrapper.__name__ = func.__name__ wrapper.soap_descriptor = FunctionDescriptor(func,*params, **kwparams) return wrapper
  • 8. Sebesség: lxml!
  • 9. Szolgáltatás
  • 10. from soaplib.serializers.clazz import ClassSerializerclass Organization(ClassSerializer): class types: name = String domain_name = String created = DateTime account_id = String def __init__(self, obj=None): super(Organization, self).__init__() if obj is not None: self.name = obj.name self.domain_name = obj.domain_name self.created = obj.created self.account_id = obj.account_idclass OrganizationService(DjangoSOAP): __tns__ = urn:genie:service:api @soapmethod(String, identity.soap_data.Identity, soap_data.Organization, order.soap_data.Customer, _returns=soap_data.Organization) def create(self, token, admin, org, customer): [...] o = Organization.objects.get(...) [...]
  • 11. def __init__(self, ns=None): self._xs_type_ = xs:string self.__tns__ = nsdef to_xml(self, name, value, ns=None, nsmap={}): if value is None: return Null.to_xml(name, value, ns, nsmap) if type(value) != unicode: value = unicode(value, utf-8) element = create_element(name, ns, nsmap) element.text = value element.set({%s}type % XSI_NS, self._xs_type_) return elementdef from_xml(self, element): type = element.get({%s}type % XSI_NS, self._xs_type_) if type != self._xs_type_: raise InvalidXSDTypeError() if element.text is None: return None try: u = unicode(element.text) return u.encode(utf-8) except:
  • 12. Kliens
  • 13. from service import soapmethod, SoapServicefrom serializers.primitive import String, Integerfrom serializers.clazz import ClassSerializerfrom client import SoapClientclass GetBalanceRequestType(ClassSerializer): __tns__ = urn:ebay:apis:eBLBaseComponents class types: Version = String GetAllCurrencies = Stringclass PayPalService(SoapService): __tns__ = urn:ebay:api:PayPalAPI @soapmethod(GetBalanceRequestType) def GetBalanceReq(self, GetBalanceRequest): passc = SoapClient(https://foo, PayPalService(),cert_key.pem)print c.GetBalanceReq(GetBalanceRequestType(Version="55.0",GetAllCyrrencies="1"), headers=soap_headers)