0 Replies Latest reply on Dec 28, 2004 6:16 AM by jurrien

    access secured (Basic) webservice from session EJB in the sa

    jurrien

      I have 2 ears running in my server (Jboss4.0.0).
      One ear contains the webservices, the other my EJB app.
      The webservices are protected with basic authentication.
      If I connect to the webservice with a java client all works fine.
      If I use the same code in a session bean deployed in the same server but different ear I get following error: authorization required.
      If I remove the basic authentication from the webservice all works fine from both the java client and session Bean. But I really need security.
      The code I use in the bean and java client is identical:

      Call call = service.createCall(port);
      call.setTargetEndpointAddress(endpoint);
      call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
      call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
      call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
      call.setProperty(Call.USERNAME_PROPERTY,"user");
      call.setProperty(Call.PASSWORD_PROPERTY,"password");
      QName QNAME_TYPE_INT = new QName(NS_XSD, "integer");
      QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
      call.setReturnType(QNAME_TYPE_INT);
      String BODY_NAMESPACE_VALUE = "http://user.frontend.gsmservice.sygel.com";
      call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "sendMessage"));
      call.addParameter("number", QNAME_TYPE_STRING, ParameterMode.IN);
      call.addParameter("message", QNAME_TYPE_STRING, ParameterMode.IN);
      String[] params = { mobileNumber, subject + " " + body};
      java.math.BigInteger resultInt = (java.math.BigInteger) call.invoke(params);