使用paypal api时无法建立SOAP连接

时间:2014-01-22 14:12:24

标签: java web-services soap paypal

我正在尝试使用paypal soap客户端,并使用Paypal Express Checkout with Java引用执行setExpressCheckout方法。

  

所以在这里我只使用paypal-base.jar和paypal-stubs.jar   soap客户端(由wsdl生成)。

    public class SetExpressCheckoutService{

        private static Logger log = Logger.getLogger(SetExpressCheckoutService.class);

        public static void main(String[] args){
            SetExpressCheckoutService setExpressCheckoutService = new SetExpressCheckoutService();

            //the parameters for the service
            Long userId = 5l;
            String amount = "25";
            String returnURL = "http://localhost:8080/integratingstuff-paypal/return_after_payment.xhtml";
            String cancelURL = "http://localhost:8080/integratingstuff-paypal/cancel_payment.xhtml";
            PaymentActionCodeType paymentAction = PaymentActionCodeType.Sale;
            CurrencyCodeType currencyCode = CurrencyCodeType.EUR;

            try {
                //calling the service, setting up the checkoutpage
                String token = setExpressCheckoutService.setExpressCheckout(userId, amount, currencyCode, returnURL,cancelURL,paymentAction);
                log.info("Url to redirect to: https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=" + token);
            } catch (PayPalException e) {
                log.error(e);
            }
        }

        public String setExpressCheckout(Long userId, String paymentAmount,
                CurrencyCodeType currencyCodeType, String returnURL, String cancelURL,
                    PaymentActionCodeType paymentAction) throws PayPalException{



CallerServices caller = new CallerServices();

            //construct and set the profile, these are the credentials we establish as "the shop" with Paypal
            APIProfile profile = ProfileFactory.createSignatureAPIProfile();
            profile.setAPIUsername("sdk-three_api1.sdk.com");
            profile.setAPIPassword("QFZCWN5HZM8VBG7Q");
            profile.setSignature("AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ");
            profile.setEnvironment("sandbox");
            caller.setAPIProfile(profile);

            //construct the request
            SetExpressCheckoutRequestType pprequest = new SetExpressCheckoutRequestType();
            pprequest.setVersion("63.0");

            //construct the details for the request
            SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();

            PaymentDetailsType paymentDetails = new PaymentDetailsType();
            paymentDetails.setOrderDescription("Integrating Stuff Test Order");
            paymentDetails.setInvoiceID("INVOICE-" + Math.random());
            BasicAmountType orderTotal = new BasicAmountType(paymentAmount);
            orderTotal.setCurrencyID(currencyCodeType);
            paymentDetails.setOrderTotal(orderTotal);
            paymentDetails.setPaymentAction(paymentAction);
            details.setPaymentDetails(new PaymentDetailsType[]{paymentDetails});

            details.setReturnURL(returnURL);
            details.setCancelURL(cancelURL);
            details.setCustom(userId.toString());

            //set the details on the request
            pprequest.setSetExpressCheckoutRequestDetails(details);

            //call the actual webservice, passing the constructed request
            SetExpressCheckoutResponseType ppresponse = (SetExpressCheckoutResponseType) caller.call("SetExpressCheckout", pprequest);

            //get the token from the response
            return ppresponse.getToken();
        }
    }

我试图执行这个方法,但我得到例外的例外 com.paypal.sdk.exceptions.FatalException: Unable to establish SOAP connection

  

引起:java.lang.NullPointerException           在com.paypal.sdk.core.APICallerBase.getEndpointUrl(APICallerBase.java:296)

完整的堆栈跟踪是:

com.paypal.sdk.exceptions.FatalException: Unable to establish SOAP connection
        at com.paypal.sdk.core.soap.SOAPAPICaller.setupConnection(SOAPAPICaller.java:292)
        at com.paypal.sdk.services.CallerServices.setAPIProfile(CallerServices.java:112)
        at com.imedicor.liferay.organizations.util.PaypalService.setExpressCheckout(PaypalService.java:92)
        at com.imedicor.liferay.organizations.util.PaypalService.testing(PaypalService.java:43)
        at org.apache.jsp.organization_005fdetails_jsp._jspService(organization_005fdetails_jsp.java:500)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
        at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:323)
        at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:134)
        at com.imedicor.liferay.organizations.portlet.OrganizationPortlet.doView(OrganizationPortlet.java:83)
        at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:218)
        at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:319)
        at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
        at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
        at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
        at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
        at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:534)
        at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:607)
        at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:359)
        at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1207)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:97)
        at com.liferay.portal.servlet.PACLRequestDispatcherWrapper.doDispatch(PACLRequestDispatcherWrapper.java:90)
        at com.liferay.portal.servlet.PACLRequestDispatcherWrapper.include(PACLRequestDispatcherWrapper.java:54)
        at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:5158)
        at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:1569)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:165)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:203)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:190)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:87)
        at com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor.processMax(TemplateProcessor.java:165)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
        at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
        at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
        at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
        at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
        at org.apache.velocity.Template.merge(Template.java:328)
        at org.apache.velocity.Template.merge(Template.java:235)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:381)
        at com.liferay.portal.velocity.VelocityEngineImpl.mergeTemplate(VelocityEngineImpl.java:264)
        at com.liferay.portal.kernel.velocity.VelocityEngineUtil.mergeTemplate(VelocityEngineUtil.java:73)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doProcessTemplate(RuntimePortletImpl.java:499)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doDispatch(RuntimePortletImpl.java:394)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processTemplate(RuntimePortletImpl.java:228)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:125)
        at org.apache.jsp.html.portal.layout.view.control_005fpanel_jsp._jspService(control_005fpanel_jsp.java:676)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
        at com.liferay.portal.action.LayoutAction.includeLayoutContent(LayoutAction.java:468)
        at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:735)
        at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:187)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:560)
        at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:537)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
        at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:138)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:335)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:241)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.etag.ETagFilter.processFilter(ETagFilter.java:56)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:246)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
        at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:216)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
        at com.paypal.sdk.core.APICallerBase.getEndpointUrl(APICallerBase.java:296)
        at com.paypal.sdk.core.soap.SOAPAPICaller.setupConnection(SOAPAPICaller.java:193)

所以我因为没有设置终点url而得到这个异常?

在这种情况下如何设置终点网址?

我还尝试在启动上述方法时以下列方式添加端点配置。

Map<String, String> sdkConfig = new HashMap<String, String>();
        sdkConfig.put("mode", "sandbox");
        sdkConfig.put("acct1.UserName", "sdk-three_api1.sdk.com");
        sdkConfig.put("acct1.Password", "QFZCWN5HZM8VBG7Q");
        sdkConfig.put("acct1.Signature","AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ");
        PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(sdkConfig);

但我仍然得到同样的例外。

请在这方面指导我。

谢谢,

2 个答案:

答案 0 :(得分:4)

好的,所以我没有设法找出为什么CallerService抛出提到的异常,因为即使在反编译提到paypal_base.jar之后,代码也非常繁琐,而且很难找到正在发生的事情。引擎盖。看起来它已经过时了,因为除了几个地方,我无法在网上的任何地方找到对这个JAR的引用。

但我真的建议您坚持使用PayPal提供的原始文档。我试过自己,这就是我发现的:

  1. 按照上述文章中的Paypal API SDK and Downloads链接,然后点击Merchant类别下的Classic APIs链接(如果您在网上挖掘,您会发现PayPal Merchant API应该用于ExpressCheckout请求)。点击上方的Java按钮,然后使用Maven(首选)或仅使用页面底部的下载链接下载SDK。

  2. 将下载的JAR添加到您的项目中并删除其他PayPal JAR,因为下载的Merchant API jar应包含所有必需的类。

  3. 现在一切都在猜测:)所以在你上面的代码片段中你已经形成了SetExpressCheckoutRequestType的实例,你需要some invocation code来获取SetExpressCheckoutRequestType的实例并返回{的实例{1}}。
  4. 我在Eclipse中使用了功能SetExpressCheckoutResponseType来查找Search -> References -> Workspace jar中SetExpressCheckoutRequestType的使用位置。此搜索显示(除了其他地方)有一个名为Merchant API的类,其方法为SetExpressCheckoutReq
  5. 然后,我再次使用搜索功能搜索setSetExpressCheckoutRequest(SetExpressCheckoutRequestType)类的用法,发现有SetExpressCheckoutReq类,其中方法PayPalAPIInterfaceServiceService返回所需的setExpressCheckout(SetExpressCheckoutReq setExpressCheckoutReq)
  6. SetExpressCheckoutResponseType方法旁边,有一个方法也接受setExpressCheckout(SetExpressCheckoutReq setExpressCheckoutReq)参数并具有以下签名: ICredential
  7. 再次使用Eclipse我查找了实现setExpressCheckout(SetExpressCheckoutReq setExpressCheckoutReq, ICredential credential)接口的类,发现有一个名为ICredential的类,构造函数有3个参数:用户名,密码,签名。这对我来说似乎还有很长的路要走。

    所以,非常近似 - 代码片段现在应该是:

    SignatureCredential
  8. final SetExpressCheckoutRequestType ppRequest = ...; // here you create your request as in code snippet above final Properties serviceConfigurationProperties = ...; // bookmark #1 final PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(serviceConfigurationProperties); final SetExpressCheckoutReq request = new SetExpressCheckoutReq(); request.setSetExpressCheckoutRequest(ppRequest); final ICredentials credentials = new SignatureCredentials(username, password, signature); final SetExpressCheckoutResponseType response = service.setExpressCheckout(request, credentials); :应该通过Bookmark #1实例传递服务配置。要找出应该指定哪些属性,应该谷歌为它并尝试坚持原始的PayPal文档而不是第三方博客:)如果在Properties类的Javadocs中查找,他/她发现有文件提到“sdk_config.properties”。在谷歌搜索之后,我发现了该文件的几个示例:Example #1Example #2

    请注意,这不是完整的解决方案 - 它更像是我以前用过PayPal SOAP API的一系列提示。这个API经常变化而不是简洁的文档,所以我真的建议用源代码下载PayPalAPIInterfaceServiceService jar,并且每当出现问题时 - 查看代码 - 这通常会澄清很多。还请坚持使用PayPal的原始文档:

    1. PayPal SOAP API Basics
    2. PayPal Merchant SDK on GitHub
    3. 此外,如果您没有使用Java的Web服务客户端的经验,我建议您尝试使用网络上的教程来实现一些简单的 - 这可能会澄清很多。

      再次抱歉没有发布完整而简洁的代码片段 - 我从现在起2年没有使用过PayPal,当时我花了一周时间查找所有细节并设置并运行。请发帖问题 - 我会在有空的时候尝试回答问题

      希望这会有所帮助......

      修改

      关于Merchant API返回response.getAck() - 过去我也遇到过这样的问题。我通过试验请求中发送的参数来解决这个问题 - FAILURE对这些参数非常敏感,如果省略任何参数或者没有正确的值,只需返回PayPal

      可在此处找到完整的参数列表: PayPal SetExpressCheckout SOAP API documentation

      另请注意,FAILURE的{​​{1}}版本使用版本为2.5.106的API。

      希望这会有所帮助......

答案 1 :(得分:0)

您需要设置端点网址

    service.EndPoint=https://api-3t.paypal.com/2.0

此外,您可能还需要更多设置:

    service.Binding=SOAP
    service.EndPoint=https://api-3t.paypal.com/2.0
    service.RedirectURL=https://www.paypal.com/webscr&cmd=
    service.DevCentralURL=https://developer.paypal.com
    service.IPNEndpoint=https://www.paypal.com/cgi-bin/webscr

如果您使用的是沙箱,请使用以下设置:

   service.Binding=SOAP
   service.EndPoint=https://api-3t.sandbox.paypal.com/2.0
   service.RedirectURL=https://www.sandbox.paypal.com/webscr&cmd=
   service.DevCentralURL=https://developer.paypal.com
   service.IPNEndpoint=https://www.sandbox.paypal.com/cgi-bin/webscr