QuickBooks不适用于Google App Engine

问题描述 投票:1回答:2

我试图通过运行这个简单的代码从谷歌应用引擎在线连接到quickbooks:

OAuthCredentials oauthcredentials = new OAuthCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);

PlatformSessionContext context = new PlatformSessionContext(oauthcredentials, appToken, PlatformServiceType.QBO, realmID);

QBCustomerService customerService = QBServiceFactory.getService(context, QBCustomerService.class);

QBIdType idType = new QBIdType(context);

idType.setValue("2");

QBCustomer c = customerService.findById(context, idType);

System.err.println(c.getName());

它总是抛出这个错误:

com.intuit.ds.qb.IDSException: java.net.SocketException: Operation failure: Unknown error.
    at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:105)
    at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:118)
    at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:82)
    at com.google.appengine.api.socket.AppEngineSocketImpl.setSocketOptionAsBytes(AppEngineSocketImpl.java:229)
    at com.google.appengine.api.socket.AppEngineSocketOptions$BooleanCheckFunction.apply(AppEngineSocketOptions.java:168)
    at com.google.appengine.api.socket.AppEngineSocketOptions$Option.validateAndApply(AppEngineSocketOptions.java:358)
    at com.google.appengine.api.socket.AppEngineSocketOptions$Option.validateAndApply(AppEngineSocketOptions.java:373)
    at com.google.appengine.api.socket.AppEngineSocketImpl.setOption(AppEngineSocketImpl.java:144)
    at com.google.appengine.api.socket.AppEngineSocketImpl.setOption(AppEngineSocketImpl.java:171)
    at java.net.Socket.setTcpNoDelay(Socket.java:950)
    at sun.security.ssl.BaseSSLSocketImpl.setTcpNoDelay(BaseSSLSocketImpl.java:330)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.prepareSocket(DefaultClientConnectionOperator.java:222)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:153)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
    at com.intuit.ds.qb.IDSRestClient.sendRequest(IDSRestClient.java:557)
    at com.intuit.ds.qb.IDSRestClient.get(IDSRestClient.java:160)
    at com.intuit.ds.qb.qbo.QBOService.getQBOBaseURI(QBOService.java:24)
    at com.intuit.ds.qb.IDSRestClient.setServiceTypeProperty(IDSRestClient.java:698)
    at com.intuit.ds.qb.qbo.QBORequestCreator.doIDSGet(QBORequestCreator.java:41)
    at com.intuit.ds.qb.qbo.AbstractQBOBaseDataService.findById(AbstractQBOBaseDataService.java:185)
    at com.intuit.ds.qb.qbo.QBOCustomerService.findById(QBOCustomerService.java:153)
    at com.xyz.server.tasks.SyncCustomerTask.runMethod(SyncCustomerTask.java:85)
    at com.xyz.server.tasks.SyncCustomerTask.run(SyncCustomerTask.java:33)
    at com.google.apphosting.utils.servlet.DeferredTaskServlet.performRequest(DeferredTaskServlet.java:136)
    at com.google.apphosting.utils.servlet.DeferredTaskServlet.service(DeferredTaskServlet.java:99)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:57)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:438)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
    at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:722)

在我的代码中,com.xyz.server.tasks.SyncCustomerTask.runMethod(SyncCustomerTask.java:85)findbyId("2")行。有什么建议如何解决这个问题?任何帮助都会非常贴切

google-app-engine intuit-partner-platform quickbooks-online
2个回答
2
投票

AppEngine仅提供有限的Socket API。特别是,你不能使用大多数getsockopt / setsockopt调用,在你的情况下抛出错误(setTcpNoDelay(..))。

QuickBooks SDK似乎是封闭源代码,因此没有办法解决它。

更新:

GAE Java SDK 1.8.1。开始,可以使用套接字选项方法:它们是无操作的,但它们不会像过去那样抛出异常:

The Sockets API now allows client code to call get/set options against sockets. Previously, calls raised "Not Implemented" exceptions. When java.net.Socket.get<option>() is called, a mock value is returned, calls to set<option>() will be silently ignored.


0
投票

我很感谢你发布了这个问题。除了我用Go语言而不是Java开发我的谷歌应用程序之外,我一直在用相同的问题敲打墙头几天。但我做了它的工作!我希望我的解决方案也能帮到你。基本上,我没有使用套接字服务,而是使用URL Fetch服务,这里记录了Java:https://developers.google.com/appengine/docs/java/urlfetch/

我对你原帖中的一些细节很不了解(我没有用Java开发,也不熟悉QBServiceFactory和OAuthCredentials)。所以我不确定你对它如何实际向QB发送请求有多少控制权。但最糟糕的情况是,我认为您可以编写自己的函数来替换QBServiceFactory(我必须在Go中执行),如果您确保使用URL Fetch服务而不是套接字,那么您可能会更好运气。

正如我所说,我非常感谢你的问题,因为我不认为我会偶然发现我的答案,谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.