将字节数组从 Blackberry 传递到 .NET Webservice

发布于 2024-07-23 04:46:02 字数 551 浏览 7 评论 0原文

我正在尝试将字节数组从我的 Blackberry 应用程序发送到 .NET Web 服务 (asmx)。

我使用 Sun Java Wireless Toolkit (WTK) 2.5.2 生成要在 Blackberry 解决方案中使用的 Web 服务存根。 WTK 项目设置正在使用 JSR 172 规范生成存根。

我已经使用 .NET 2005 创建了 Web 服务,使用以下方法:

[WebMethod]
public string UploadImage(byte[] Data, string Name)
{
  //do stuff
}

我从该 Web 服务的 WSDL 生成存根,但收到:“错误:发现未知的简单类型:byte[]”。 我已经使用了这种生成存根的方法,并且之前没有收到任何错误,因为所有输入变量都是简单类型,但我使用它来返回自定义对象的数组。 当我检查 WSDL 文件时,类型是 base64Binary。

除了字节数组之外,我还可以使用其他东西来传递数据吗? 或者我是否缺少某种设置来允许网络服务将其作为字节数组?

I am trying to sent a byte array from my Blackberry application to a .NET webservice (asmx).

I am using the Sun Java Wireless Toolkit (WTK) 2.5.2 to generate the webservice stubs to use within the Blackberry solution. The WTK project settings are producing the stubs using the JSR 172 specification.

I have created the Webservice using .NET 2005, using the following method:

[WebMethod]
public string UploadImage(byte[] Data, string Name)
{
  //do stuff
}

I generate the stubs from the WSDL of this webservice but I am receiving: "error: Found unknown simple type: byte[]". I've used this method of generating stubs and I've not received any errors before, granted all input variables have been simple types but I've used this to return arrays of custom objects. When I check the WSDL file the type is base64Binary.

Is there something I can use other than the byte array to pass the data in? Or is there some sort of setting that I am missing to allow the webservice to take it a byte array?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Smile简单爱 2024-07-30 04:46:02

最好的办法可能是将参数指定为字符串。 Base64 是二进制数据的 ASCII 表示形式。

The best thing to do is probably just specify the parameter as a String. Base64 is ASCII representation of binary data.

三月梨花 2024-07-30 04:46:02

您可以使用 String 而不是 byte[] 来声明您的方法。
您可以在客户端使用以下代码片段:

byte[] chunk = ...;
String data= Base64OutputStream.encodeAsString(chunk, 0, chunk.length, false, false);
UploadImage(data, name)

and on the server side you can use:

byte[] byteArray;
byteArray = Base64.decode(data);

you have the declare your method with String instead of byte[].
Than you can use the following snippet on the client side:

byte[] chunk = ...;
String data= Base64OutputStream.encodeAsString(chunk, 0, chunk.length, false, false);
UploadImage(data, name)

and on the server side you can use:

byte[] byteArray;
byteArray = Base64.decode(data);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文