-1

So, I've been given a WSDL link through which I have to consume soap services.As I'm running my java code I get an Exception : Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: An error was discovered processing the header After trying Testsuit from soupUi I'm receiving the same error ns1:InvalidSecurity An error was discovered processing the <wsse:Security> header I'm pretty new to SOAP web services.Can anyone please guide me steps how to add headers in java code for authentication. Thank you :)

Programmer
  • 29
  • 2
  • 9
  • Can you give the stack trace of the SOAPFaultException ? – rjdkolb Jan 21 '16 at 08:31
  • com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source) at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source) at com.sun.proxy.$Proxy21.isPermitted(Unknown Source) at com.prakash.soap.test.main(test.java:69) – Programmer Jan 21 '16 at 08:33
  • This should help http://stackoverflow.com/questions/7071366/java-web-service-client-basic-authentication – rjdkolb Jan 21 '16 at 08:36
  • Actually I do not even have the format how the data will be send through the header :( – Programmer Jan 21 '16 at 08:41
  • Why do you need the format ? It's just a username and password right ? JAX-WS should do it all for you with the linked stackoverflow answer. – rjdkolb Jan 21 '16 at 08:43
  • As I said I'm preety new to SOAP web services.Can you please tell me how to check which famework its using cuz As far as I've done till now .I have extracted the java classes using wsimport and copied them to my standalone java-project. – Programmer Jan 21 '16 at 08:47
  • And if needed to add JAX-WS how'd be that done. – Programmer Jan 21 '16 at 08:48
  • Like you said, you have used wsimport to import the WSDL, so it's already JAX-WS and JAX-WS is apart of your Java install. Follow tutorials like http://www.javatips.net/blog/2012/09/java-wsimport-tool-example – rjdkolb Jan 21 '16 at 08:53
  • So I used this LookupService lookupservice=new LookupService(); Lookup port = lookupservice.getLookupPort(); BindingProvider prov = (BindingProvider)port; prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName); prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,userPassword); port.getAllServices(); ANd I'm Still getting the same error at port.getAllServices() – Programmer Jan 21 '16 at 10:01
  • Try the same call with SOAP UI first and verify that it works – rjdkolb Jan 21 '16 at 10:05
  • Still cant. Same error ns1:InvalidSecurity An error was discovered processing the <wsse:Security> header – Programmer Jan 21 '16 at 10:37
  • Can you please guide me how and where to specify the username and password?I'm stuck and i need it to be done.Thank You – Programmer Jan 22 '16 at 07:11
  • Did you try Soap UI first as I suggested ? – rjdkolb Jan 22 '16 at 07:21
  • Yes I did.I also have posted the response I've got from server – Programmer Jan 22 '16 at 07:41
  • At the bottom left order of the SOAP UI request window, there is a "Auth" button. Add a basic type auth with your user name and password – rjdkolb Jan 22 '16 at 07:43
  • Yes I've done that and I'm getting the response like ns1:InvalidSecurity An error was discovered processing the <wsse:Security> header – Programmer Jan 22 '16 at 08:08
  • Then you must ask another question on Stackoverflow if this happens with Soap ui – rjdkolb Jan 22 '16 at 08:11
  • I have added soapui tag to this and edited the question.Lets hope some experts can help me out with this issue ad thanks for your support :) – Programmer Jan 22 '16 at 08:33

1 Answers1

0

Okay I have Fixed this issue I had to manually add custom headers to my request message. But for this I had to detach previous header and then append my custom header to the request message. I hope next time someone getting this type of exception may get some help from this.

Programmer
  • 29
  • 2
  • 9