询问关于java客服端代码调用.net WebService后,服务端的得到的数据为null
java 客户端代码import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
public class testService {
/**
* @param args
* @throws RemoteException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatException, RemoteException {
// TODO Auto-generated method stub
String url = "http://localhost:1483/test/Service.asmx?wsdl";
Service service = new Service();
Call call;
Integer resultInfo = null;
Integer Status = null;
String retunValue="";
try {
call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(url));
call
.setOperationName(new QName(
"http://tempuri.org",
"WZSPCheckProcessUpdateByStatusAndId"));
call.removeAllParameters();
String Id="test1";
call.addParameter(new javax.xml.namespace.QName("http://tempuri.org","Id"),
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
Status = new Integer(99);
call.addParameter(new javax.xml.namespace.QName("http://tempuri.org","Status"),
org.apache.axis.Constants.XSD_INTEGER,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
call.setUseSOAPAction(true);
call
.setSOAPActionURI("http://tempuri.org/testcheck");
retunValue = (String)( call
.invoke(new Object[] {Id, Status }));
System.out.print(retunValue);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
。net服务端代码
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function WZSPCheckProcessUpdateByStatusAndId(ByVal Id As String, ByVal status As Integer) As String
Return Id
End Function
webservice端拿到的值始终为NULL,请问如何解决 --------------------编程问答-------------------- NameSpace的问题
前面有人也是这个情况
java默认http://tempuri.org
。Net是http://tempuri.org/
后者最后多了个/,改成一样就行了 --------------------编程问答-------------------- --------------------编程问答-------------------- UP
补充:.NET技术 , Web Services