简体   繁体   English

应用内购买向服务器发送交易收据

[英]In-App-Purchase Sending Transaction Receipt to server

I've created an e-book reader app & it supports in-app-purchase. 我已经创建了一个电子书阅读器应用程序,它支持应用程序内购买。 The transaction receipt which gets generated is being sent to a jboss server. 生成的交易收据将被发送到jboss服务器。 The following piece of code has been written to send the transaction receipt to server. 编写了以下代码,以将交易收据发送到服务器。 here i'm converting .xml file to NSdata & passing the NSdata object to server. 在这里,我将.xml文件转换为NSdata并将NSdata对象传递到服务器。

-(IBAction)download:(id)sender{
    NSString *XMLPath = [[NSBundle mainBundle] pathForResource:@"ebook" ofType:@"xml"];

    NSString *name = @"photo1"; 
    NSData *imageData = [NSData dataWithContentsOfFile:XMLPath];
    NSLog(@"size of imageDATA %d",imageData.length);
    //NSString *Datastring = [NSString strin]
    NSString *dataString = [[NSString alloc] initWithData:imageData encoding:NSUTF8StringEncoding];
    //transaction.transactionReceipt;
    //NSData * imageData = UIImagePNGRepresentation(image); 
    // NSString *postLength = [NSString stringWithFormat:@"%d", [imageData length]];        
    NSString *urlString = @"http://172.18.11.162:8080/DRM_15April/ReceiptDownload";
    //urlString = [urlString stringByAppendingString:@"tranReceipt"];
    //urlString = [urlString stringByAppendingString:@"&name="];
    //urlString = [urlString stringByAppendingString:name]; 
    //urlString = [urlString stringByAppendingString:@"&lang=en_US.UTF-8"]; 
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    NSLog(@"the url is %@",urlString);
    [request setHTTPMethod:@"POST"];
    NSMutableData *postBody = [NSMutableData data];



    //add data field and file data
    [postBody appendData:[NSData dataWithData:imageData]];
    NSLog(@"size of DATA %d",postBody.length);
    // ---------

    [request setHTTPBody:postBody];

    // now lets make the connection to the web
    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

    NSLog(@"return strind is %@",returnString);

}

This is logging the following in my console window. 这是在我的控制台窗口中记录以下内容。

-[KitabooBookShelf download:] the url is http://172.18.11.162:8080/DRM_15April/ReceiptDownload
(1) -[KitabooBookShelf download:] size of DATA 364
(1) -[KitabooBookShelf download:] return strind is <html><head><title>JBossWeb/2.0.1.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.io.StreamCorruptedException: invalid stream header: 3C3F786D
    java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)
    java.io.ObjectInputStream.&lt;init&gt;(ObjectInputStream.java:279)
    com.hurix.drm.servlet.ReceiptDownload.doPost(ReceiptDownload.java:40)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    com.hurix.drm.common.filter.SessionFilter.doFilter(SessionFilter.java:75)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the JBossWeb/2.0.1.GA logs.</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.1.GA</h3></body></html>

can anyone suggest me what could be going wrong at my application side. 谁能建议我在应用程序方面可能出了什么问题。

You trying to read an XML data with an ObjectInputStream, but as the javadoc says: 您尝试使用ObjectInputStream读取XML数据,但是正如javadoc所说:

An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream. ObjectInputStream反序列化原始数据和先前使用ObjectOutputStream写入的对象。

So actually there is nothing wrong on client side, but on server side. 因此,实际上,客户端没有错,但是服务器端没有错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM