描述:使用C#做了一个webservice,部署到IIS上后,通过点击IIS上浏览在浏览器中打开webservice可以正常使用webservice中的方法,但是通过java调用发布到IIS上的webservice方法时出现方法调用过程中
引用的dll的方法的失败。想了一下以前遇到过一个问题,asp.net程序使用现在的照片处理类库时出现过同样的问题,也没报错,就是方法执行失败。最后通过将程序设置成32位的才解决问题,当时的情况时,在一台开发笔记本上(当时笔记本上装了vs2015,C++相关类库)64位编译的程序能正常使用,在另一台电脑上64位编译的程序不能正常使用,改成32位编译后就能使用了。
1.C#编写的webservice
2.webservice属于web程序无法设置直接设置32或者64位程序,只能在部署到IIS中的时候在创建应用程序池的时候设置允许32位
3.java调用C#webservice中的方法
package com.wxzy.ydxt; import java.rmi.RemoteException; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; import javax.xml.rpc.ServiceException; import javax.xml.rpc.encoding.XMLType; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class DecryImage { public static Boolean DecryImg(String originalImagePath,String targetImagePath){ String url = "http://127.0.0.1:1002/ImageUtilWebService.asmx"; String namespace = "http://127.0.0.1:1002/"; //namespace 在此处运行时没起作用可以随便怎么写或 String methodName = "DecryImage"; String soapActionURI = "http://127.0.0.1:1002/DecryImage"; //ip:port 和c#中的webservice保持一致就行了 Service service=new Service(); Call call; try{ call = (Call) service.createCall(); call.setTargetEndpointAddress(url); call.setUseSOAPAction(true); call.setSOAPActionURI(soapActionURI); call.setOperationName(new QName(namespace, methodName)); call.addParameter(new QName(namespace, "originalImagePath"), XMLType.XSD_STRING,ParameterMode.IN); call.addParameter(new QName(namespace, "targetIamgePath"), XMLType.XSD_STRING,ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); String[] str = new String[2]; str[0] = originalImagePath; str[1] = targetImagePath; Object obj = call.invoke(str); System.out.println(obj); } catch(ServiceException e){ e.printStackTrace(); } catch(RemoteException e){ e.printStackTrace(); } return false; } }
4.在调用测试过程中,我发现java发送调用请求后,C#是正常加载了dll引用的,但是就是方法执行失败。将IIS中发布的webservice的应用程序池改成允许32位后就能成功执行了。