java调用c#开发的webservice为什么传入的参数为空
java调用c#开发的webservice为什么传入的参数为空,在本地点击调用却可以正常传参,请大侠指点,谢谢! --------------------编程问答-------------------- 你用什么方式调用的webservice?POST 还是 SOAP ? --------------------编程问答-------------------- SOAP --------------------编程问答-------------------- java调用c#开发的webservice为什么传入的参数为空,在本地点击调用却可以正常传参,请大侠指点,谢谢!这是net的代码
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld(string arg0,string arg1) {
return arg0+"-Hello World-"+arg1;
}
[WebMethod]
public string HelloWorld2()
{
return "-Hello ytWorld-";
}
}
java调用的代码
public static String GetWS2(String s1,String s2)
{
String output= "";
try {
String endpoint="http://localhost:31380/ws2/Service.asmx";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://tempuri.org","HelloWorld"));
call.addParameter(new QName("http://tempuri.org","arg0"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org","arg1"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setSOAPActionURI("http://tempuri.org/HelloWorld");
Object[] s = new Object[]{s1,s2};
output=(String)call.invoke(new Object[]{"df","fff"});
System.out.println( "result is " + output + ".");
}
catch (Exception e) {System.err.println(e.toString());}
return output;
} --------------------编程问答--------------------
找到问题了,你自己看看吧:
http://www.cnblogs.com/ucetgg/archive/2009/06/23/1509668.html
http://www.cnblogs.com/mmmjiang13/archive/2011/04/07/2007629.html --------------------编程问答-------------------- 谢谢isjoe,按你给的帖子修改了代码,可是还是传入参数为空 --------------------编程问答-------------------- 大家看看http://localhost:31380/ws2/Service.asmx?WSDL 有问题没
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types />
- <wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="arg0" type="s:string" />
<wsdl:part name="arg1" type="s:string" />
</wsdl:message>
- <wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="HelloWorldResult" type="s:string" />
</wsdl:message>
- <wsdl:message name="HelloWorld2SoapIn">
<wsdl:part name="s" type="s:string" />
</wsdl:message>
- <wsdl:message name="HelloWorld2SoapOut">
<wsdl:part name="HelloWorld2Result" type="s:string" />
</wsdl:message>
- <wsdl:portType name="ServiceSoap">
- <wsdl:operation name="HelloWorld">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">根据产品编号查询产品的价格</wsdl:documentation>
<wsdl:input message="tns:HelloWorldSoapIn" />
<wsdl:output message="tns:HelloWorldSoapOut" />
</wsdl:operation>
- <wsdl:operation name="HelloWorld2">
<wsdl:input message="tns:HelloWorld2SoapIn" />
<wsdl:output message="tns:HelloWorld2SoapOut" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
<soap:operation soapAction="http://tempuri.org/HelloWorld" style="rpc" />
- <wsdl:input>
<soap:body use="literal" namespace="http://tempuri.org/" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" namespace="http://tempuri.org/" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="HelloWorld2">
<soap:operation soapAction="http://tempuri.org/HelloWorld2" style="rpc" />
- <wsdl:input>
<soap:body use="literal" namespace="http://tempuri.org/" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" namespace="http://tempuri.org/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
<soap12:operation soapAction="http://tempuri.org/HelloWorld" style="rpc" />
- <wsdl:input>
<soap12:body use="literal" namespace="http://tempuri.org/" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" namespace="http://tempuri.org/" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="HelloWorld2">
<soap12:operation soapAction="http://tempuri.org/HelloWorld2" style="rpc" />
- <wsdl:input>
<soap12:body use="literal" namespace="http://tempuri.org/" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" namespace="http://tempuri.org/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Service">
- <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address location="http://localhost:31380/ws2/Service.asmx" />
</wsdl:port>
- <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address location="http://localhost:31380/ws2/Service.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions> --------------------编程问答-------------------- 再次顶起,达人给解决下,谢谢了 --------------------编程问答-------------------- 怎么解决的,最近也遇到这问题,郁闷中。
补充:.NET技术 , Web Services