I am trying to consume a net web service using Pearl and SOAP Lite.
When I consume web services in the net client - it posts .asmx to the following posts:
How can I get the same request using SOAP Lite? I have done different types of SOAP light docs and articles in which there is no luck so far I have the following:
#! / Usr / bin / perl SOAP :: Light 'trace', 'debug'; $ Api_ns = "https://mysoapnamespace.com"; $ Api_url = "http: //mysoapnamespace/api.asmx"; $ Action = "HelloWald"; My $ SOAP = SOAP :: Light - & gt; Readable (1) - & gt; Yuri ($ API_N) - & gt; Proxy ($ api_url) - & gt; On_action (sub {return "\" $ action \ ""}); Return Soap- & gt; HellowWorld (); This generates this, Wrong XML:
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Soaps: envelope xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: soapenc = "http://schemas.xmlsoap.org/soap/encoding/" xmlns: XSD = "Http : //www.w3.org/2001/XMLSchema "Soap: encoding style =" http://schemas.xmlsoap.org/soap/encoding/ "xmlns: soap =" http://schemas.xmlsoap.org/ soap / Envelope / "& gt; & Lt; Soaps: Body & gt; & Lt; HellowWorld xmlns = "http://mysoapnamespace.com" xsi: nil = "true" /> & Lt; / Soap: Body & gt; & Lt; / Soap: Envelope & gt; Update:
When I give 1 xml using Fiddler, it returns my "Hello World" result when I post 2 If I do, I get the following:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Soaps: Envelope xmlns: Soap = "http: //schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http : //www.w3.org/001/XmlSchema "& gt; & Lt; Soaps: Body & gt; & Lt; Soap: defect & gt; & Lt; Faultcode & gt; Soaps: Customers & lt; / Faultcode & gt; & Lt; Faultstring & gt; System.Web.Services.Protocols.SoapException: The server was unable to read the request. --- & amp; Gt; System.InvalidOperationException: There is an error in the XML document (9, 6). --- & amp; Gt; System.Invalid Operation Exception: & amp; ;; HellowWorld xmlns = 'http: //mysoapnamespace.com'& Gt; Not expected Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read21_HellowWorld () on Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfjectSerializer28.Deserialize (XmlSerializationReader Reader) on System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, string encoding style, XmlDeserializationEvents events) --- Internal Exception Stack Trace Termination --- System.Xml.Serialization.XmlSerializer.Deserialize on System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader XmlReader, string encodingStyle, XmlDeserializationEvents events) (XmlReader XmlReader, string encodingStyle ) On System.Web.Services.Protocols.SoapServerProtocol.ReadParameters () --- the end of the inner exception stack trace Ti --- System.Web.Services.Protocols.SoapServerProtocol.ReadParameters () on System.Web.Services.Protocols.WebServiceHandler at CoreProcessRequest () & lt; / Faultstring & gt; & Lt; Extension / & gt; & Lt; / Soap: defect & gt; & Lt; / Soap: Body & gt; & Lt; / Soap: Envelope & gt;
issue found - trailing slash at namespace. .Net only statistics tell you that there is stuff for you, but it is clearly needed to be set in perl. Also, we find out how to add the ns () function to add name spaces.
This will generate the correct XML.
#! / Usr / bin / perl Usage SOAP :: Light 'Trace', 'Debug'; $ Api_ns = "https://mysoapnamespace.com/"; $ Api_url = "http: //mysoapnamespace/api.asmx"; $ Action = "HelloWald"; My $ SOAP = SOAP :: Light - & gt; Readable (1) - & gt; Ns ($ API_type, 'type') - & gt; Ns ($ API_N, 'TNS') - & gt; Proxy ($ api_url) - & gt; On_action (sub {return "\" $ action \ ""}); Return Soap- & gt; HellowWorld ();
This link was very useful in finding SOAP :: Lite -
Comments
Post a Comment