关于java调用C#开发的webservice的问题

over1982 2008-10-25 11:07:09
困扰很久了,
我开发的C#的webservice ,需要参数string ,可是对方java在调用的时候,我接受到的string参数老是为空
如果是int 参数,我收到的是0;
对方查看我的wsdl,看到的类型是s:string,他说他们都是xsd:string ,所以要我改,可是我不知道怎么改
请高手指点
...全文
2386 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
pay300 2012-07-09
  • 打赏
  • 举报
回复
llshanks 2012-06-13
  • 打赏
  • 举报
回复
顶一个。。。
lingsuikaixin 2011-06-13
  • 打赏
  • 举报
回复
你是.net开发的,那你知道.net如何调用java的webservice接口吗?
zhouxingyu896 2011-06-12
  • 打赏
  • 举报
回复
要调用者 使用 java的axis或者xfire 框架来 调用呢
C#写得服务,用java好调用的很。


简单龙卷风 2011-06-02
  • 打赏
  • 举报
回复
那个webservice里面的数据怎么读取出来呈现在前台jsp中呢?
filon51 2010-04-06
  • 打赏
  • 举报
回复
有报错:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://121.52.210.101/Service.asmx
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1196)
at my.SOAPClient4XG.WebServiceClient(SOAPClient4XG.java:98)
at my.SOAPClient4XG.main(SOAPClient4XG.java:29)
Exception Occured!
much0726 2008-11-01
  • 打赏
  • 举报
回复
汗,提交没反应,不小心跨了两楼
much0726 2008-11-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 jiezi316 的回复:]
改什么哟?让他们改,呵呵
我写的WEB服务,我们公司的JAVA开发人员都调得好好的啊。
[/Quote]
是啊,总要有一边要改的,一般都是客户端要改,服务端不用改.
我没有写过JAVA客户段,但知道怎么修改.NET客户端和JAVA服务段通信.
.NET和JAVA的很多服务框架还不能直接通信的,真麻烦.
much0726 2008-11-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 jiezi316 的回复:]
改什么哟?让他们改,呵呵
我写的WEB服务,我们公司的JAVA开发人员都调得好好的啊。
[/Quote]
是啊,总要有一边要改的,一般都是客户端要改,服务端不用改.
我没有写过JAVA客户段,但知道怎么修改.NET客户端和JAVA服务段通信.
.NET和JAVA的很多服务框架还不能直接通信的,真麻烦.
gtiroy 2008-10-29
  • 打赏
  • 举报
回复
学习
jiezi316 2008-10-29
  • 打赏
  • 举报
回复
改什么哟?让他们改,呵呵
我写的WEB服务,我们公司的JAVA开发人员都调得好好的啊。
NIJIA72 2008-10-27
  • 打赏
  • 举报
回复
帮你顶一下
much0726 2008-10-27
  • 打赏
  • 举报
回复
我也有遇到类似问题:
一般是两种环境的包类型不一样,
比如:
java 调用的helloworld方法发送的包为:

<soap:body>
<helloworld>helloworld</helloworld>
<soap:body>


c# 中需要的是:

<soap:body>
<helloworld>
<hellostr>helloworld</hellostr>
</helloworld>
<soap:body>

只是举个例子,实际上可能不是这样,关键是你要抓包看看,具体POST的包,再进行分析.
按你的问题分析,估计只要在参数前面加个[XmlText]
就可以解决
比如:

[WebMethod]
public string HelloWorld([XmlText]String param)
{
//...
}
周公 2008-10-26
  • 打赏
  • 举报
回复
  本文介绍一个非常实用的Java客户端工具类来调用C# WebServices和apache XML rpc server,这个类的源码是从网上下载的,我在博客网做项目的时候一直使用这个类来调试C# WebServices和MetaWeblog API。顺便在这里也给大家介绍一下C#如何处理此类发送的xml数据。
使用这个类不用安装任何第三方工具,因为采用http的方式发送xml文件,所以你只需要安装好JDK就可以了。执行此类还可以获得WebServices或xml rpc server返回的xml字符流,你可以根据返回的xml数据来进行其他程序处理。通过这种方式实现了Java平台和.NET平台的数据交换和WebService调用。
下面是此类的源代码SOAPClient4XG.java:

/** 
* SOAPClient4XG. Read the SOAP envelope file passed as the second
* parameter, pass it to the SOAP endpoint passed as the first parameter, and
* print out the SOAP envelope passed as a response. with help from Michael
* Brennan 03/09/01
*
*
* @author Bob DUCharme
* @version 1.1
* @param SOAPUrl URL of SOAP Endpoint to send request.
* @param xmlFile2Send A file with an XML document of the request.
*
* 5/23/01 revision: SOAPAction added
*/

import java.io.*;
import java.net.*;

public class SOAPClient4XG {
public static void main(String[] args) throws Exception {

if (args.length < 2) { //小于
System.err.println("Usage: java SOAPClient4XG " +
"http://soapURL soapEnvelopefile.xml" +
" [SOAPAction]");
System.err.println("SOAPAction is optional.");
System.exit(1);
}

String SOAPUrl = args[0];
String xmlFile2Send = args[1];

String SOAPAction = "";
if (args.length > 2) //大于
SOAPAction = args[2];

// Create the connection where we're going to send the file.
URL url = new URL(SOAPUrl);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;

// Open the input file. After we copy it to a byte array, we can see
// how big it is so that we can set the HTTP Cotent-Length
// property. (See complete e-mail below for more on this.)

FileInputStream fin = new FileInputStream(xmlFile2Send);

ByteArrayOutputStream bout = new ByteArrayOutputStream();

// Copy the SOAP file to the open connection.
copy(fin,bout);
fin.close();

byte[] b = bout.toByteArray();

// Set the appropriate HTTP parameters.
httpConn.setRequestProperty( "Content-Length",
String.valueOf( b.length ) );
httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
httpConn.setRequestProperty("SOAPAction",SOAPAction);
httpConn.setRequestMethod( "POST" );
httpConn.setDoOutput(true);
httpConn.setDoInput(true);

// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();
out.write( b );
out.close();

// Read the response and write it to standard out.

InputStreamReader isr =
new InputStreamReader(httpConn.getInputStream());
BufferedReader in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}

// copy method from From E.R. Harold's book "Java I/O"
public static void copy(InputStream in, OutputStream out)
throws IOException {

// do not allow other threads to read from the
// input or write to the output while copying is
// taking place

synchronized (in) {
synchronized (out) {

byte[] buffer = new byte[256];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) break;
out.write(buffer, 0, bytesRead);
}
}
}
}
}


编译:javac SOAPClient4XG.java
运行的命令格式: java -classpath . SOAPClient4XG http://localhost/BokeServices/Service1.asmx c:loginReq.xml http://tempuri.org/UserLoginReq,不过先不要运行上面的命令,先介绍一下命令行的意思,http://localhost/BokeServices/Service1.asmx是C# WebService的地址,c:loginReq..xml里的内容是调用的WebService方法的xml文件, http://tempuri.org是WebService方法的命名空间,一定要有,否则调用失败,假如你在C# WebServices中使用了方法默认的命名空间的话,就使用http://tempuri.org,否则要与C#中定义的一致,UserLoginReq是C# WebServices的方法名。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧