4 Replies Latest reply: Jan 11, 2013 5:46 AM by user696 RSS

    Issue in Calling https webservice calls from Weblogic

    979732
      Hi,

      My application is hosted on the weblogic server.

      I am trying to call http basic authenticated webservice from my application.
      But I am not able to access it. I am getting error.

      Exception occured while calling WS : 2 counts of InaccessibleWSDLException.
      com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
      java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'https://somehost/ws/xyz.wsdl'
      java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'https://somehost/ws/xyz.wsdl?wsdl'

      I have added the code to authenticate the request. But it seems that it is not working from weblogic.

      class MyAuthenticator extends Authenticator {
      @Override
      protected PasswordAuthentication getPasswordAuthentication() {

      PasswordAuthentication pwa = new PasswordAuthentication(
      "uname",
      "pwd".toCharArray());
      return pwa;
      }
      }

      Authenticator authenticator = new MyAuthenticator();
      Authenticator.setDefault(authenticator);

      PaymentService webForm=new PaymentService(wsURL, getDefaultQName(PaymentService.class)); ---> Exception occurs here.
      PaymentWebForm sessionService=webForm.getPaymentSoap11();
      response=sessionService.getSession(wfSessionRequest);


      Please help. This is not working only from weblogic however if I execute it from standalone Java client then it worked without any issue.

      Is there any configuration needs to be done in Weblogic for secure webservice calls? Please advise.


      Thanks,
      -Pankaj Chomal
        • 1. Re: Issue in Calling https webservice calls from Weblogic
          792089
          The same probolem happened in my side.
          1.web.xml
          <security-role>
          <description>role for acess the WS api</description>
          <role-name>Admin</role-name>
          </security-role>
          <security-constraint>
          <web-resource-collection>
          <web-resource-name>web service api</web-resource-name>
          <url-pattern>/ws/*</url-pattern>

          </web-resource-collection>
          <auth-constraint>
          <role-name> Admin</role-name>
          </auth-constraint>
          <user-data-constraint>
          <transport-guarantee>NONE</transport-guarantee>
          </user-data-constraint>
          </security-constraint>
          <login-config>
          <auth-method>BASIC</auth-method>
          </login-config>
          2.weblogic.xml have you done?
          <security-role-assignment>
          <role-name>Admin</role-name>
          <principal-name>Administrators</principal-name> //weblogic server group
          </security-role-assignment>
          3.1 calling in a Main method , it works!
          Authenticator.setDefault(new Authenticator() {
               protected PasswordAuthentication getPasswordAuthentication() {
               return new PasswordAuthentication("wsuser", "12345678".toCharArray());
               }
               });
          HrWebService hws = new HrWebServiceService().getHrWebServicePort();
          System.out.println("Result:====="+ hws.getEmpInfoByQryContent("100384"));
          com.jl.ws.hello.AuthHello ah = new AuthHelloImplService().getAuthHelloImplPort();
               System.out.println(ah.say("Edward"));
          }
          3.2 each method as following(including the method above mentioned) called failed in a jsp page, any good idea?

          method a:
          javax.security.auth.Subject mySubject = weblogic.security.services.Authentication.login(
                    new weblogic.security.URLCallbackHandler("wsuser", "12345678"));
          weblogic.servlet.security.ServletAuthentication.runAs(mySubject, request);

          method b:
          javax.security.auth.callback.CallbackHandler handler = new weblogic.security.URLCallbackHandler("wsuser", "12345678");
          javax.security.auth. Subject mySubject = weblogic.security.services.Authentication.login(handler);
          weblogic.servlet.security.ServletAuthentication.runAs(mySubject, request);

          method c:
          weblogic.servlet.security.ServletAuthentication.login("wsuser", "12345678", request,response);

          4. excpeiton message
          javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://localhost:7001/jlerp/ws/hr/hrSearch?wsdl. It failed with:
               Response: '401: Unauthorized' for url: 'http://localhost:7001/jlerp/ws/hr/hrSearch?wsdl'.
               at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:172)
               at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:153)
               at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:284)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:246)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:197)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:187)
               at weblogic.wsee.jaxws.spi.WLSServiceDelegate.(WLSServiceDelegate.java:73)
               at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.(WLSProvider.java:515)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:103)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:95)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:71)
               at javax.xml.ws.Service.(Service.java:56)
               at com.jl.ws.hr.HrWebServiceService.(HrWebServiceService.java:53)
               at com.jl.ws.HrSearchClient.hell0(HrSearchClient.java:32)
               at jsp_servlet._de._jsp.__dejjuserlist._jspService(__dejjuserlist.java:136)
               at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
               at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
               at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
               at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
               at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
               at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
               at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
               at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
               at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
               at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
          Caused by: java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'http://localhost:7001/jlerp/ws/hr/hrSearch?wsdl'
               at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:474)
               at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:37)
               at java.net.URL.openStream(URL.java:1010)
               at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:842)
               at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:289)
               at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:138)
               at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:284)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:246)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:198)
               at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:190)
               at weblogic.wsee.jaxws.spi.WLSServiceDelegate.(WLSServiceDelegate.java:62)
               at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.(WLSProvider.java:515)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:103)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:95)
               at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:71)
               at javax.xml.ws.Service.(Service.java:56)
               at com.jl.ws.hr.HrWebServiceService.(HrWebServiceService.java:54)
               at com.jl.ws.HrSearchClient.hell0(HrSearchClient.java:32)
               at jsp_servlet._de._jsp.__dejjuserlist._jspService(__dejjuserlist.java:138)
               ... 10 more
          any info is thankful.

          Edited by: EdwardXiao on Jan 8, 2013 10:48 PM
          • 2. Re: Issue in Calling https webservice calls from Weblogic
            user696
            how about running local copy of wsdl instead of server side?

            Regards,
            Sunil P
            • 3. Re: Issue in Calling https webservice calls from Weblogic
              792089
              The exception I got just from running local copy, and
              I used the wsimport -s ./src -p com.jl.ws.hr -Xnocompile -Xauthfile auth.txt(where content is username:password@{wsld location}) {wsdl location} to generate the java client source code( no letter is modified)

              another way I want to try ,but still failed. source code chip :
              public class AuthHelloImplService
              extends Service
              {

              private final static URL AUTHHELLOIMPLSERVICE_WSDL_LOCATION;
              private final static Logger logger = Logger.getLogger(com.jl.ws.hello.AuthHelloImplService.class.getName());

              static {
              ........................
              AUTHHELLOIMPLSERVICE_WSDL_LOCATION = url;
              }
              public AuthHelloImplService() {
              super(AUTHHELLOIMPLSERVICE_WSDL_LOCATION, new QName("http://ws.jl.com/", "AuthHelloImplService")); //exception occured here ,code 401.........

              }
              @WebEndpoint(name = "AuthHelloImplPort")
              public AuthHello getAuthHelloImplPort() {
              AuthHello ah = super.getPort(new QName("http://ws.jl.com/", "AuthHelloImplPort"), AuthHello.class);
              // web service invoking authenticate, exception occured before the logic running.
              BindingProvider db = (BindingProvider)ah;
              db.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"wsuser");
              db.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "12345678");
              return ah;
              }

              PS: when I used the first way in tomcat server, it works well.

              regards,
              Edward

              Edited by: EdwardXiao on Jan 9, 2013 4:50 PM

              Edited by: EdwardXiao on Jan 9, 2013 5:02 PM

              Edited by: EdwardXiao on Jan 9, 2013 7:17 PM
              • 4. Re: Issue in Calling https webservice calls from Weblogic
                user696
                It should not fail when your using local copy of wsdl if it still failing which might require additional debug, at least it should not fail when fetching the WSDL since your loading local copy
                Caused by: java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'http://localhost:7001/jlerp/ws/hr/hrSearch?wsdl'


                I would suggest to open SR with Weblogic Web service team to debug further more on issue.