ffrost has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to work in SOAP::Lite to create a SOAPAction and a SOAP method call where the XMLNS in the method call has a trailing '/' at the end. Below I'll post what I've got so far, what it creates, and what I'm trying to create for comparison. I'm a bit stumped on getting the training '/' added, but I know it will work if can get it that way, as it works in LWP. Some information has been obscured due to necessity.

## EXISTING RELEVANT CODING:
$soapreg = SOAP::Lite ->proxy($regws) ->uri ("$regns") ->autotype(0); $results = $soapreg -> $regmethod (SOAP::Data->name('username') ->value($cun), SOAP::Data->name('password') ->value($cpw), SOAP::Data->name('status') ->value('1'), SOAP::Data->name('filter') ->value($testdata));
## CURRENT OUTPUT CREATED (debug):
SOAP::Transport::HTTP::Client::send_receive: POST https://(url.com)/xx +x/service.asmx HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 621 Content-Type: text/xml; charset=utf-8 SOAPAction: https://(url.com)/xxx/UserInfo <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding +/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <UserInfo xmlns="https://(url.com)/xxx"> <username>OMIT</username> <password>OMIT</password> <status>1</status> <filter>9876533</filter> </UserInfo> </soap:Body></soap:Envelope>
## DESIRED OUTPUT (can't get the extra slash at the end in UserInfo)
SOAP::Transport::HTTP::Client::send_receive: POST https://(url.com)/xx +x/service.asmx HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 621 Content-Type: text/xml; charset=utf-8 SOAPAction: https://(url.com)/xxx/UserInfo <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding +/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <UserInfo xmlns="https://(url.com)/xxx/"> <username>OMIT</username> <password>OMIT</password> <status>1</status> <filter>9876533</filter> </UserInfo> </soap:Body></soap:Envelope>
This should be easy to do, but I can't figure out how. If I modify $regns to "https://(url.com)/xxx/" (extra slash at the end) then it creates an invalid SOAPAction request (https://(url.com)/xxx//UserInfo) which breaks the application. We don't have control of the server so nothing can be done on that end, unfortunately.

Replies are listed 'Best First'.
Re: SOAP::Lite attribute modification on method
by ffrost (Acolyte) on May 30, 2021 at 21:13 UTC
    Made a modification to the top to fix it, and added the slash at the end of $regns and the output looks right and I'm finally getting a response. I guess going over the code and posting it here provided some insight I kept overlooking.

    use SOAP::Lite on_action => sub {sprintf '%s%s', @_}; $regns='https://(url.com)/xxx/';