2011-05-19 115 views
-1

我可以在C#.net替换此代码到JavaWeb服务通信

[WebMethod] 
    public int SendSMS(string Message, ref string MessageReturn) { 
     string _res = string.Empty; 
     _res = "defalt message"; 
     MessageReturn = _res; 
     return 0; 
    } 

我不知道

回答

0

不一定要用Java参考字符串类型那么容易,因为我们不能传递对字符串的引用以及该方法中该位置的值。

解决方法:包裹串中的字符串数组

public int SendSMS(String message, String[] messageReturn) { 
    if (messageReturn == null || messageReturn.length != 1) { 
     throw new AssertionError("Need to pass a length-1-String array"); 

    String res = ""; 
    res = "defalt message"; 
    messageReturn[0] = res; 
    return 0; 
} 
+0

这是web服务,客户端是由.NET writen,它使用REF变量。所以我写了一个web服务来与.net客户端进行通信。问题是我不知道java中的ref字符串。 – 2011-05-20 04:27:55