0

I'm writing a SOAP::Lite client to work with a SOAP server that sometimes sends responses that are missing a namespace specification. This is the first time I've ever done anything with SOAP, so I'm not very knowledgeable at all. Here is an example response:

HTTP/1.1 200 OK
Server: "OS/version" UPnP/1.0 "product/version"
Content-Length: 83219
Content-Type: text/xml; charset="UTF-8"
Client-Date: Tue, 01 Aug 2017 06:30:44 GMT
Client-Peer: 192.168.1.123:5000
Client-Response-Num: 1

<?xml version="1.0" encoding="UTF-6"?>
<soap-env:Envelope
        xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
        soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >
<soap-env:Body>
    <m:GetDataResponse
        xmlns:m="urn:BLACKBOX:service:DataSource:1">
        <DataBlob xsi:type="xsd:base64Binary">Ikf7SPJ...SsA==</DataBlob>
    </m:GetDataResponse>
    <ResponseCode>0</ResponseCode>
</soap-env:Body>
</soap-env:Envelope>

Notice the use of the 'xsi' namespace without specification. There should probably be one for 'xsd' too? SOAP::Lite is giving me this error message:

failed:  Unresolved prefix 'xsi' for attribute 'xsi:type'

How would I work around this with SOAP::Lite in the client, given that I have no control of the server? Is there some way for me to tell SOAP::Lite to assume namespaces I provide?

froage
  • 1
  • 1

2 Answers2

0

The server is broken and you should raise an error. Meanwhile, you could get your code working by editing the incoming data, adding

these definitions to the Envelope element

xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Borodin
  • 126,100
  • 9
  • 70
  • 144
  • Yes, I did realize the server is broken and that I want those two definitions added to the Envelope element, but what I need is a description of how to actually use SOAP::Lite to accomplish that editing. – froage Aug 01 '17 at 19:03
  • There's a kind of live stream of the Perl Conference in Amsterdam at https://twitter.com/steve_mynott/status/895222263695409153 if you're interested. – simbabque Aug 09 '17 at 11:59
  • @simbabque: Thank you. – Borodin Aug 31 '17 at 15:42
  • Welcome back! :) I missed you. – simbabque Aug 31 '17 at 15:52
  • 1
    @simbabque: Thank you. I doubt if many people share your sentiment! I wish wouldn't do that.I sent you a tweet; did you get it? – Borodin Aug 31 '17 at 15:53
  • I did not unfortunately. But I found it now and wrote a private message there. – simbabque Aug 31 '17 at 15:57
  • I just submitted a talk for the London Perl Workshop in November this year. Maybe we can have that pint finally. And if you don't plan to attend I am happy to extend my stay and come to Reading to collect it. There's nothing like a train ride through the London suburbs in dreadful late-autumn weather I guess. – simbabque Sep 05 '17 at 15:16
  • @simbabque: Sadly I'm in Edinburgh for the foreseeable future caring for my elderly mother while I work. Reading is where I took my degree, but that was in 1978—I'm normally in Norwich these days. What will your subject be? – Borodin Sep 05 '17 at 22:06
  • Oh, that's a shame. Some other time then. My talk will be about training junior developers. I've already done a lightning talk about that in Amsterdam. This one is going to be longer though. – simbabque Sep 05 '17 at 22:16
  • @simbabque: I'll catch it on Youtube if it's posted there. – Borodin Sep 05 '17 at 22:40
0

Just add to SOAP::Lite object:

$soap->serializer->register_ns('http://www.w3.org/2001/XMLSchema' => 'xmlns:xsd');

$soap->serializer->register_ns('http://www.w3.org/2001/XMLSchema-instance' => 'xmlns:xsi');
rahed h
  • 41
  • 1
  • That cannot work. I need a solution for namespace definitions missing from the incoming SOAP response, not the outgoing request. Is there a way to register such definitions with the **de**serializer so that it will use them when they are missing in the actual incoming response XML? – froage Aug 02 '17 at 21:58