Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. from requests import Session
  2. from zeep import Client
  3. from zeep.transports import Transport
  4.  
  5. if __name__ == "__main__":
  6.  
  7. url="http://localhost:8080/Wormhole?wsdl"
  8.  
  9. with open('../../web/web/xsd/DETEP2012-with-content.xml', 'r') as f:
  10. xml=f.read().replace('n', '')
  11.  
  12. session = Session()
  13. session.verify = False
  14. transport = Transport(session=session)
  15. client = Client(url, transport=transport)
  16.  
  17. print client.service.PubMugs(username='usr',password='pwd') #SUCCESS
  18.  
  19. print client.service.subscribe(username='usr',password='pwd') #SUCCESS
  20.  
  21. print client.service.post(username='usr',password='pwd',mug='110',XML_BODY=xml) #SUCCESS
  22.  
  23. client = Savon.client(wsdl: ENV["WSDL"],
  24. :ssl_verify_mode => :none,
  25. :raise_errors => false,
  26. pretty_print_xml: true)
  27.  
  28. doc = File.open("../web/web/xsd/DETEP2012-with-content.xml") { |f| Nokogiri::XML(f) }
  29.  
  30. xml = doc.to_xml.delete("n").split(">",2)[1] # Removes initial <?xml ... >
  31.  
  32. ap xml # The XML here looks correct
  33.  
  34. response_pub_mugs = client.call(:pub_mugs, message: { username: "usr", password: "pwd" } )
  35.  
  36. ap response_pub_mugs #SUCCESS
  37.  
  38. response_subscribe = client.call(:subscribe, message: { username: "usr", password: "pwd" } )
  39.  
  40. ap response_subscribe #SUCCESS
  41.  
  42. #THIS CALL FAILS!
  43. response_post = client.call(:post,
  44. message: {
  45. username: "usr",
  46. password: "pwd",
  47. mug: "110",
  48. XML_BODY: xml
  49. }
  50. )
  51.  
  52. :fault => {
  53. :faultcode => "S:Server",
  54. :faultstring => "java.lang.NullPointerException",
  55. :"@xmlns:ns4" => "http://www.w3.org/2003/05/soap-envelope"
  56. }
  57.  
  58. SEVERE: null
  59. java.lang.NullPointerException
  60. at seti.Wormhole.post(Wormhole.java:103)
  61. at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
  62. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  63. at java.lang.reflect.Method.invoke(Method.java:606)
  64. at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
  65. at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
  66. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  67. at java.lang.reflect.Method.invoke(Method.java:606)
  68. at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
  69.  
  70. <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://seti/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://seti/" name="Wormhole">
  71. <types>
  72. <xsd:schema>
  73. <xsd:import namespace="http://seti/" schemaLocation="http://localhost:8080/Wormhole?xsd=1"/>
  74. </xsd:schema>
  75. </types>
  76. <message name="PubMugs">
  77. <part name="parameters" element="tns:PubMugs"/>
  78. </message>
  79. <message name="PubMugsResponse">
  80. <part name="parameters" element="tns:PubMugsResponse"/>
  81. </message>
  82. <message name="post">
  83. <part name="parameters" element="tns:post"/>
  84. </message>
  85. <message name="postResponse">
  86. <part name="parameters" element="tns:postResponse"/>
  87. </message>
  88. <message name="subscribe">
  89. <part name="parameters" element="tns:subscribe"/>
  90. </message>
  91. <message name="subscribeResponse">
  92. <part name="parameters" element="tns:subscribeResponse"/>
  93. </message>
  94. <portType name="Wormhole">
  95. <operation name="PubMugs">
  96. <input wsam:Action="http://seti/Wormhole/PubMugsRequest" message="tns:PubMugs"/>
  97. <output wsam:Action="http://seti/Wormhole/PubMugsResponse" message="tns:PubMugsResponse"/>
  98. </operation>
  99. <operation name="post">
  100. <input wsam:Action="http://seti/Wormhole/postRequest" message="tns:post"/>
  101. <output wsam:Action="http://seti/Wormhole/postResponse" message="tns:postResponse"/>
  102. </operation>
  103. <operation name="subscribe">
  104. <input wsam:Action="http://seti/Wormhole/subscribeRequest" message="tns:subscribe"/>
  105. <output wsam:Action="http://seti/Wormhole/subscribeResponse" message="tns:subscribeResponse"/>
  106. </operation>
  107. </portType>
  108. <binding name="WormholePortBinding" type="tns:Wormhole">
  109. <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
  110. <operation name="PubMugs">
  111. <soap:operation soapAction=""/>
  112. <input>
  113. <soap:body use="literal"/>
  114. </input>
  115. <output>
  116. <soap:body use="literal"/>
  117. </output>
  118. </operation>
  119. <operation name="post">
  120. <soap:operation soapAction=""/>
  121. <input>
  122. <soap:body use="literal"/>
  123. </input>
  124. <output>
  125. <soap:body use="literal"/>
  126. </output>
  127. </operation>
  128. <operation name="subscribe">
  129. <soap:operation soapAction=""/>
  130. <input>
  131. <soap:body use="literal"/>
  132. </input>
  133. <output>
  134. <soap:body use="literal"/>
  135. </output>
  136. </operation>
  137. </binding>
  138. <service name="Wormhole">
  139. <port name="WormholePort" binding="tns:WormholePortBinding">
  140. <soap:address location="http://localhost:8080/Wormhole"/>
  141. </port>
  142. </service>
  143. </definitions>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement