Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS-Security headers #19

Open
eraad opened this issue Apr 5, 2019 · 8 comments
Open

WS-Security headers #19

eraad opened this issue Apr 5, 2019 · 8 comments

Comments

@eraad
Copy link

eraad commented Apr 5, 2019

Hi!

I'm trying to build a request for a SOAP service that requires WS-Security headers. It expects a call like this:

Screen Shot 2019-04-05 at 06 14 50

I tried associating a map with the expected headers into the mapping like so:

(assoc-in mapping ["Envelope" "Header"] {"wsse:Security" {"wsse:UsernameToken" {"wsse:Username" "a" "wsse:Password" "c"}}})

The problem is that the wrap-body fn seems to ignore this. Can you shed a light on how to add this type of headers into the SOAP envelope? Thanks!

@DeLaGuardo
Copy link
Contributor

@eraad
All tags that can occurs multiple times within another must be wrapped into an object with a key in plural.
E.g.

{"Headers" [{"Header" {"Security" {"UsernameToken" {"Username" {:__value "a"}
                                                    "Password" {:__value "c"}}}}}]} 

Please check your request mapping structure.
If my assumption is correct this code should work:

(assoc-in mapping ["Envelope" "Headers"] 
  [{"Header" {"Security" {"UsernameToken" {"Username" "a" "Password" "c"}}}}])

It also would be helpful if you will post your mapping here.

@eraad
Copy link
Author

eraad commented Apr 5, 2019

Hi @DeLaGuardo

I tried it but did not work. Please, find my mapping below:

=> (def m (service/request-mapping srv))
=> {Envelope {Header {}, Body {sendBill {fileName {:__value {:__type string, :__optional? true}}, contentFile {:__value {:__type nil, :__optional? true}}, partyType {:__value {:__type string, :__optional? 
true}}}}}}
=> (assoc-in m ["Envelope" "Headers"] [{"Header" {"Security" {"UsernameToken" {"Username" {:__value "a"} "Password" {:__value "c"}}}}}])
=> {Envelope {Header {}, Body {sendBill {fileName {:__value 1234-01-123F-1.XML}, contentFile {:__value #object[[B 0x5279f71 [B@5279f71]}}}, Headers [{Header {Security {UsernameToken {Username {:__value a}, Password {:__value c}}}}}]}}
=> <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:ser="http://service.sunat.gob.pe"><soapenv:Header/><soapenv:Body><ser:sendBill><fileName>1234-01-123F-1.XML</fileName><contentFile>[B@5279f71</contentFile></ser:sendBill></soapenv:Body></soapenv:Envelope>

Please note that the mapping produced by request-mapping includes a Header tag (not in plural). Thanks! I appreciate your help.

@DeLaGuardo
Copy link
Contributor

Is it possible also to send your WSDL file as well?

@eraad
Copy link
Author

eraad commented Apr 5, 2019

For sure, please find it attached (zipped). I just added two more files that are included (ns and XSD).
Archive.zip

@DeLaGuardo
Copy link
Contributor

So, I can confirm that this is a bug caused by wsdl with no information about headers. I will try to add ability to inject custom handlers to fix that. Probably will solve it during upcoming weekend.

@eraad
Copy link
Author

eraad commented Apr 5, 2019

Thanks! I suspected that. I will keep an eye on the project! Shall I close this issue?

@DeLaGuardo
Copy link
Contributor

Let's leave it open until resolved

@lwiechec
Copy link

I have a similar issue. Would there be a chance to fix it?... if not - could you point me where to look for? maybe I can help fixing it somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants