当前位置: 代码迷 >> Web Service >> java调用C# webservice传值替null
  详细解决方案

java调用C# webservice传值替null

热度:411   发布时间:2013-10-11 14:52:39.0
java调用C# webservice传值为null?
本帖最后由 ddrsun 于 2013-09-29 10:33:02 编辑
这样的,我C#开放了个webservice接口,参数是三个string类型的,java和C#的string难道不一样?
java那边调用了,
但,经调试,java调用传过来的值都为null,这是为什么?
谢谢各位搭救了!

c#接口

/// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://BSKJ_WEB_SERVICE.COM/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
        
        [WebMethod(Description = "提货(参数:提货类型、JSON参数、MIP工作流ID)")]
        public bool PickUpGoods(string getType, string data, string processID)
        {
            try
            {
                //bool tof = false;
                MakeLog mk = new MakeLog();
                mk.Insertlog(getType, data, processID);
               
                //PickUpdateStock pug = new PickUpdateStock();
              
                ////tof = pug.UpdateTH(getType, data, processID);
                ////if (pug.UpdateTH(getType, data, processID)) return true;
                //if ( pug.UpdateTH(getType, data, processID) ) return true;
                //else return false;
            }
            catch (Exception ex)
            {
                MakeLog mk = new MakeLog();
                mk.Insertlog("NoticeLogs", ex.ToString(), "");
                return false; 
            }
            return true;
        }
    }

java的调用代码如下:

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

String endpoint = "http://localhost:54715/Service1.asmx?WSDL";
String SOAPActionURI =  "http://BSKJ_WEB_SERVICE.COM/PickUpGoods";
  Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//call.setOperationName("KmReviewWebService");

call.setUseSOAPAction(true);
call.setSOAPActionURI(SOAPActionURI);
call.setOperationName("PickUpGoods"); 
String[] str = {"DGTH", "sdfd","sdf"};
System.out.println( call.invoke((Object[]) str));
  
}
webservice

------解决方案--------------------
java 可以用 cxf 或者 axis的 wsdl2java 直接生成代理的。


我推断还是类型没匹配,比如 Object[] 直接当成第一个参数传过去了。


------解决方案--------------------
  相关解决方案