我正在使用.net开发的Web服务。 我的平台是IBM RAD,WebSphere 7和jax rpc。
我编写代码来调用服务,获得低于空指针的异常。 客户代码:
// String
// endPoint="https://pilot.id3global.com/ID3gWS/ID3global.svc/Soap11_NoAuth";
// String endPoint="BasicHttpBinding_GlobalAuthenticateStub";
// GlobalAuthentication globalAuth =new GlobalAuthentication();
Long l = new Long("0");
// globalAuth.setProfileID("4a6eaf41-f9a9-44f0-9700-81aa43004dab");
// globalAuth.setProfileVersion(l);
GlobalProfileIDVersion profileIDVersion = new GlobalProfileIDVersion();
profileIDVersion.setID("4a6eaf41-f9a9-44f0-9700-81aa43004dab");
profileIDVersion.setVersion(l);
GlobalInputData iInputData = new GlobalInputData();
GlobalPersonal personal = new GlobalPersonal();
GlobalPersonalDetails personalDetails = new GlobalPersonalDetails();
personalDetails.setForename("Raymond");
personalDetails.setSurname("Smith");
personalDetails.setDOBDay(01);
personalDetails.setDOBMonth(11);
personalDetails.setDOBYear(1951);
personalDetails.setGender(GlobalGender.Male);
personal.setPersonalDetails(personalDetails);
GlobalAddresses globalAddress = new GlobalAddresses();
GlobalAddress globalAdres = new GlobalAddress();
globalAdres.setPremise("3");
// iInputData.Addresses.CurrentAddress.Building = "";
// THis is commented out as I am just sending through a Building Number in
// Premise whereas this is used for Building Names
// iInputData.Addresses.CurrentAddress.SubBuilding = "";
// This is commented out as no Flat/Apartment is being sent
globalAdres.setStreet("High Street");
globalAdres.setCity("Westbury");
globalAdres.setZipPostcode("BA13 3BN");
globalAdres.setCountry("United Kingdom");
globalAddress.setCurrentAddress(globalAdres);
GlobalIdentityDocuments identityDocuments = new GlobalIdentityDocuments();
GlobalInternationalPassport internationalPassport = new GlobalInternationalPassport();
internationalPassport
.setNumber("1234567897GBR4511012M1803035<<<<<<<<<<<<<<00");
internationalPassport.setExpiryDay(03);
internationalPassport.setExpiryMonth(03);
internationalPassport.setExpiryYear(2018);
internationalPassport.setCountryOfOrigin("United Kingdom");
identityDocuments.setInternationalPassport(internationalPassport);
// BasicHttpBinding_GlobalAuthenticateStub stub=new
// BasicHttpBinding_GlobalAuthenticateStub("https://pilot.id3global.com/ID3gWS/ID3global.svc/Soap11_NoAuth","dfasdf");
// IGlobalAuthenticate authenticate=proxy.getIGlobalAuthenticate();
URL wsdlLocationURL = new URL(
"https://pilot.id3global.com/ID3gWS/ID3global.svc?wsdl");
// URL wsdlLocationURL = new URL("WEB-INF/wsdl/ID3global.wsdl");
// QName qname = new QName("http://www.id3global.com/ID3gWS/2013/04",
// "AuthenticateSP");
// Final===> QName qname = new
// QName("http://www.id3global.com/ID3gWS/2013/04", "ID3global");
QName qname = new QName("http://www.id3global.com/ID3gWS/2013/04",
"ID3global");
Service service = Service.create(wsdlLocationURL, qname);
QName portQName = new QName("http://www.id3global.com/ID3gWS/2013/04",
"basicHttpBinding_GlobalAuthenticate");
IGlobalAuthenticate proxy = service.getPort(portQName,
IGlobalAuthenticate.class);
/******************* UserName & Password ******************************/
Map<String, Object> req_ctx = ((BindingProvider) proxy)
.getRequestContext();
// req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
// "https://pilot.id3global.com/ID3gWS/ID3global.svc?wsdl");
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("nreddy"));
headers.put("Password", Collections.singletonList("password"));
req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
iInputData
.setAddressDocuments(new GlobalAddressDocuments());
iInputData.setAddresses(new GlobalAddresses());
iInputData
.setBankingDetails(new GlobalBankingDetails());
iInputData
.setContactDetails(new GlobalContactDetails());
iInputData.setEmployment(new GlobalEmployment());
iInputData.setGlobalGeneric(new GlobalGeneric());
iInputData.setIdentityDocuments(identityDocuments);
iInputData.setImages(new GlobalImage[1]);
iInputData.setLocation(new GlobalLocation());
iInputData.setPersonal(personal);
// GlobalResultData response = null;
try
{
GlobalResultData response = proxy.authenticateSP(profileIDVersion,
"Example12345", iInputData);
// System.out.println("out responce after the proxycall"+response.getBandText().toString());
}
catch ( RemoteException e )
{
e.printStackTrace();
}
catch ( Exception e )
{
e.printStackTrace();
}
return "";
Excepetion:
[28/1/16 11:21:37:584 EET] 00000023 SystemErr R javax.xml.ws.WebServiceException: java.lang.NullPointerException
[28/1/16 11:21:37:584 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
[28/1/16 11:21:37:585 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
[28/1/16 11:21:37:585 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
[28/1/16 11:21:37:585 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.impl.MarshalServiceRuntimeDescriptionBuilder.init(MarshalServiceRuntimeDescriptionBuilder.java:79)
[28/1/16 11:21:37:585 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.impl.MarshalServiceRuntimeDescriptionBuilder.create(MarshalServiceRuntimeDescriptionBuilder.java:52)
[28/1/16 11:21:37:585 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.MarshalServiceRuntimeDescriptionFactory.get(MarshalServiceRuntimeDescriptionFactory.java:53)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory.getMarshaller(MethodMarshallerFactory.java:111)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createRequest(JAXWSProxyHandler.java:458)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:241)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:208)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at com.sun.proxy.$Proxy27.authenticateSP(Unknown Source)
[28/1/16 11:21:37:586 EET] 00000023 SystemErr R at com.eeft.ws.ppd.AuthenticateWSBeanPortBindingImpl.callRequest(AuthenticateWSBeanPortBindingImpl.java:283)
[28/1/16 11:21:37:587 EET] 00000023 SystemErr R at com.eeft.ws.ppd.AuthenticateWSBeanPortBindingImpl.authenticate(AuthenticateWSBeanPortBindingImpl.java:73)
[28/1/16 11:21:37:587 EET] 00000023 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[28/1/16 11:21:37:587 EET] 00000023 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[28/1/16 11:21:37:588 EET] 00000023 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[28/1/16 11:21:37:588 EET] 00000023 SystemErr R at java.lang.reflect.Method.invoke(Method.java:611)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:203)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:158)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:490)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:433)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
[28/1/16 11:21:37:589 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
[28/1/16 11:21:37:590 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:153)
[28/1/16 11:21:37:590 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
[28/1/16 11:21:37:590 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
[28/1/16 11:21:37:590 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
[28/1/16 11:21:37:592 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:336)
[28/1/16 11:21:37:592 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:1246)
[28/1/16 11:21:37:592 EET] 00000023 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
[28/1/16 11:21:37:592 EET] 00000023 SystemErr R at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:344)
[28/1/16 11:21:37:592 EET] 00000023 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1700)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3994)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
[28/1/16 11:21:37:593 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
[28/1/16 11:21:37:594 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
[28/1/16 11:21:37:595 EET] 00000023 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
[28/1/16 11:21:37:595 EET] 00000023 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
[28/1/16 11:21:37:595 EET] 00000023 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
[28/1/16 11:21:37:595 EET] 00000023 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
[28/1/16 11:21:37:596 EET] 00000023 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:278)
[28/1/16 11:21:37:596 EET] 00000023 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[28/1/16 11:21:37:596 EET] 00000023 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[28/1/16 11:21:37:596 EET] 00000023 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
[28/1/16 11:21:37:596 EET] 00000023 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[28/1/16 11:21:37:597 EET] 00000023 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[28/1/16 11:21:37:597 EET] 00000023 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[28/1/16 11:21:37:597 EET] 00000023 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[28/1/16 11:21:37:597 EET] 00000023 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[28/1/16 11:21:37:597 EET] 00000023 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[28/1/16 11:21:37:598 EET] 00000023 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
[28/1/16 11:21:37:598 EET] 00000023 SystemErr R Caused by: java.lang.NullPointerException
[28/1/16 11:21:37:599 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.impl.ArtifactProcessor.getPackageName(ArtifactProcessor.java:497)
[28/1/16 11:21:37:599 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.impl.ArtifactProcessor.build(ArtifactProcessor.java:107)
[28/1/16 11:21:37:599 EET] 00000023 SystemErr R at org.apache.axis2.jaxws.runtime.description.marshal.impl.MarshalServiceRuntimeDescriptionBuilder.init(MarshalServiceRuntimeDescriptionBuilder.java:77)
[28/1/16 11:21:37:599 EET] 00000023 SystemErr R ... 52 more
我完全坚持这一点,任何帮助都会非常感激。
谢谢, 那仁
答案 0 :(得分:0)
您可能会创建错误的服务。
首先,您必须创建服务:
final Constructor<S> serviceConstructor = serviceClass.getConstructor(URL.class, QName.class);
serviceConstructor.newInstance(**null**, new QName(SERVICES_NAMESPACE, serviceName));
将param放在终点:
String endpointAddress = “http://.....”;
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
LOG.trace("Endpoint address is \"{}\".", endpointAddress);