cancel
Showing results for 
Search instead for 
Did you mean: 

"service" is null @WebServiceRef

former_member182374
Active Contributor
0 Kudos

Hello Experts,

I'm using '@WebServiceRef' in my Web Module.
Sometimes the 'service' object is null.


public class WsStaffMobile {
@WebServiceRef (name="WsAuthUserWebService") WsAuthUserService service;

public UserDetails getUserDetails(@WebParam(name = "userName") String userName, @WebParam(name = "password") String password) {
  WsAuthUser port = service.getWsAuthUserPort();
  UserDetails userDetails = port.getUserDetails(userName, password);
  return userDetails;
}

As a workaround I'm using JNDI (from this thread: http://scn.sap.com/thread/1716058) and it's working but how can I  use annotation and injection and reinitialize the object (if needed)?

J2EE version is 7.31 SP7.


Regards,
Omri
 

Accepted Solutions (0)

Answers (4)

Answers (4)

nagishetty
Explorer
0 Kudos

Hi Omri,

How did your Issue got Solved ?

Thanks,

Nagishetty

former_member182374
Active Contributor
0 Kudos

Hi,

I used the workaround from the original thread: http://scn.sap.com/thread/1716058

Omri

szymon_bolek
Participant
0 Kudos

Hi Omri,

Are you instantiate your WsStaffMobile with new?

I am not sure if the injection would work in this case.

For example if you would be using FooImplBean class generated from WSDL and call this ImplBean class as a web service reference and in this class you would have your service variable injected, than i would work.

So in your EJB project, after importing WSDLs, after generating client and java bean skeleton, you will get this code at some point, see below. In this code you will inject the service variable and call this service after retrieving port(after deployment and configuration in NWA).

@SessionHandlingDT(enableSession = false)

@AuthenticationDT(authenticationLevel = AuthenticationEnumsAuthenticationLevel.BASIC)

@TransportGuaranteeDT(level = TransportGuaranteeEnumsLevel.NONE)

@WebService(portName = "Foo_IN_Port", serviceName = "Foo_IN_Service", endpointInterface = "com.test.FooIN", targetNamespace = "http://com.test", wsdlLocation = "META-INF/wsdl/com/test/Foo_IN/Foo_IN.wsdl")

@Stateless

public class FooINImplBean {

    @WebServiceRef(name="FooResponse")  

    FooService service;

  

    @RelMessagingNW05DTOperation(enableWSRM = false)

    public  com.test.Response fooIN(com.test.RequDT foo_Requ_MT)throws com.test.fooFT_Exception {

        FooOUT port = service.getFoo_OUT_Port();

        FooRequDT requ = new FooRequDT();

        Response resp = port.fooOUT(requ);

        return resp;

     }

}

former_member182374
Active Contributor
0 Kudos

Hi,

No, I didn't solve it.

I raised an OSS and they told me that this is a "consulting issue" so I ended up using the workaround and it works.

Regards,

Omri

former_member193379
Active Contributor
0 Kudos

Hi Omri,

Please have a look of the below discussion.

http://scn.sap.com/thread/3697523

Thanks,

Hamendra

szymon_bolek
Participant
0 Kudos

Hi Omri,

Did you solve this problem of NullPointerException?

cheers

simon 🙂