java编写webservice接口net无法加载

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/nma_123456/article/details/47006513

使用java编写了webservice接口,插件使用的axis2,然后对一个java类发布webservice

现在对原函数进行修改和删除,并且又新建了几个其他的类

对新增的java类发布,并且在.net中进行调用,无法添加web引用

并且java调试跟踪报错为could't find a matching java operation for wsdd operation

.net报错org.apache.axis.configurationexception:could not find class for 

原因:在server-cpnfig.wsdd中没有对接口类和接口函数的定义,需要手动删除类或接口即可在.net中进行添加引用。

个人的一个解决办法-------不一定能解决所有问题,只给大家一个想法,希望对你有用。 

编写的webservice发布

对要发布的java类,点击右键,选择webservice,创建webservice,直接下一步下一步到完成

发布的webservice会在wsdl文件夹下添加.wsdl文件,双击进去查看wsdl文件的http路径

在本机的浏览器中输入http路径,后最添加?wsdl,看能否打开wsdl的源码页,如果可以,则发布成功。

在客户端调用http中的ip地址改为本机IP。

参考:http://blog.csdn.net/hanxuemin12345/article/details/40163757

展开阅读全文

java调用.NET的webservice接口问题

07-25

错误代码是:rnrnAxisFaultrn faultCode: http://schemas.xmlsoap.org/soap/envelope/Clientrn faultSubcode: rn faultString: Server did not recognize the value of HTTP Header SOAPAction: .rn faultActor: rn faultNode: rn faultDetail: rn http://xml.apache.org/axis/stackTrace:Server did not recognize the value of HTTP Header SOAPAction: .rn at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)rn at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)rn at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)rn at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)rn at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)rn at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)rn at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)rn at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)rn at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)rn at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)rn at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)rn at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)rn at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)rn at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)rn at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)rn at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)rn at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)rn at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)rn at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)rn at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)rn at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)rn at org.apache.axis.client.Call.invokeEngine(Call.java:2784)rn at org.apache.axis.client.Call.invoke(Call.java:2767)rn at org.apache.axis.client.Call.invoke(Call.java:2443)rn at org.apache.axis.client.Call.invoke(Call.java:2366)rn at org.apache.axis.client.Call.invoke(Call.java:2391)rnrnhttp://xml.apache.org/axis/hostname:IE361-PCrnrnrn代码为:rnrnList> List=new LinkedList>();rn rn String methodName="test";rn if (null != wsdlUrl && !"".equalsIgnoreCase(wsdlUrl)) rn logger.debug("begin------------");rn Service service = new Service();rnrn Call call;rn try rn call = (Call) service.createCall();rn rn// call.setTargetEndpointAddress(wsdlUrl);rn// call.setOperationName(new QName("http://webservice.sinosoft.com/",methodName));rn// call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//rn call.setTargetEndpointAddress(new java.net.URL(wsdlUrl));rn// rn// Object ret = call.invoke(new Object[]);rn Object ret = call.invoke(methodName, null);rn String xml=(String)ret;rn Map> Maps=parserXml(xml);rn logger.debug("-----------"+Maps.size());rn Iterator>> it=Maps.entrySet().iterator();rn while(it.hasNext())rn Map.Entry> element = (Map.Entry>) it.next();rn Map map=(Map)element.getValue();rn if(null!=map)rn List.add(map);rn rn catch (Exception e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn return List;rn rn return null;rnrnrn报错的时候是报在了rnrn Object ret = call.invoke(methodName, null);rn这一行,这一行是在webservice调用接口的方法。rn不知道这句话有什么问题,请知道的大虾帮帮忙。rnrn在网上查找过原因,说是.NET的WEBSERVICE接口服务器需要这个header,但对于apache的服务器来说,是不需要这个信息的,所以感觉比较麻烦rnrn 论坛

java如何调用c++编写webservice接口

03-30

GetSubscriptionReq req = new GetSubscriptionReq(); rn req.setSrcDeviceID("281800");rn req.setSrcDeviceType(28);rn req.setStreamingNo("10050509033001002503");rn req.setUserID("02765666640");rn req.setUserIDType(3);rn rn // init server rn String endpoint = "http://133.0.89.141:5011/IsmpCrmEngineService"; rn Service service = new Service(); rn Call call = (Call)service.createCall(); rn call.setTargetEndpointAddress(endpoint); rn QName qn = new QName("urn:BeanService", "GetSubscriptionReq"); /**这里我定义了自定义类型 TestData **/ rn call.registerTypeMapping(GetSubscriptionReq.class, qn, rn new BeanSerializerFactory(GetSubscriptionReq.class, qn), rn new BeanDeserializerFactory(GetSubscriptionReq.class, qn)); rn //set data rn call.setOperationName(new QName("urn:PortalEngine", "getSubscription"));/**这里我调用了 webservice 中的一个方法 setData ,他的参数就是我刚提到的TestData**/ rn Object[] params = new Object[] req ; rn System.out.println("---- start set data ----"); rn call.invoke(params); rn System.out.println("---- end set data ----"); rn // get data rn call.setOperationName(new QName("urn:TestService", "getData")); rn call.setReturnType(qn, GetSubscriptionReq.class); rn GetSubscriptionReq resultData = (GetSubscriptionReq)call.invoke(new Object[] ); rn System.out.println(); rn System.out.println(); rn System.out.println("---- get data ----"); rn System.out.println("--------- end --------"); rn catch (Exception e) rn e.printStackTrace(); rn 论坛

java如何调用delphi编写webservice接口

08-31

<%@ page import="org.apache.axis.client.Call"%>rn<%@ page import="org.apache.axis.client.Service"%>rn<%@ page import="org.apache.axis.encoding.XMLType"%>rn<%@ page import="javax.xml.rpc.*"%>rnrn<%@ page import="javax.xml.rpc.ParameterMode"%>rn<%@ page import="java.util.Vector"%>rn<%@page import="java.net.URL"%>rnrn<%rnService service = new Service();rnCall call = (Call)service.createCall();rn call.setTargetEndpointAddress( new URL("http://127.0.0.1/inter/RewiseInterFace.dll/wsdl/IReWiseInterFace") );rn call.setOperationName(new javax.xml.namespace.QName("GetStation"));rn // call.setUseSOAPAction(true); rn //call.setSOAPActionURI("http://www.my.com/Rpc");rn call.addParameter( "StationName", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN );rn call.addParameter( "TimeString", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN );rn call.addParameter( "ModeName", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN );rn call.addParameter( "SendBuffer", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT );rn call.addParameter( "Check", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT );rn rn call.setReturnType( XMLType.XSD_STRING );rnrnString Buffer = null;rnString Ch = null;rn String dd=(String)call.invoke(new Object[]"宾县","2007082912","DMS_AVN",Buffer,Ch);rnrn请高手帮助看看哪里出了问题?rnwsdl等描述文件在下面跟贴里!rn 论坛

java .net调用webservice接口对方无法获取参数

10-21

.net中webservice接口[code=csharp]using System;rnusing System.Collections.Generic;rnusing System.Data;rnusing System.IO;rnusing System.Text;rnusing System.Web;rnusing System.Web.Services;rnrnnamespace Ser_Managernrn /// rn /// GetForProvince 的摘要说明rn /// rn [WebService(Namespace = "http://epoint.com.cn")]rn [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]rn [System.ComponentModel.ToolboxItem(false)]rnrn public class GetForProvince : System.Web.Services.WebServicern rn [WebMethod]rn public string GetForProvinceList(string strCheckCode, string strCategoryNum)rn rn string strReturn = "";rn if (!this.GetChecked(strCheckCode, strCategoryNum))rn rn strReturn = "验证码错误!";rn return strReturn;rn rn DataView dvGG =rn Epoint.MisBizLogic2.DB.ExecuteDataView(rn "select InfoID,Title,PubInWebDate from view_infomain where InfoID!='' and categorynum='" + strCategoryNum +rn "' order by pubinwebdate desc");rn StringBuilder sb = new StringBuilder();rn sb.Append("");rn sb.Append("");rn sb.Append("");rn sb.Append("");rn sb.Append(dvGG.Count);rn sb.Append("");rn sb.Append("");rn sb.Append("");rn foreach (DataRowView drv in dvGG)rn rn //公告标识rn sb.Append("");rn sb.Append(Convert.ToString(drv["InfoID"]));rn sb.Append("");rn //公告标题rn sb.Append("");rn sb.Append(Convert.ToString(drv["Title"]));rn sb.Append("");rnrn //公告时间20160101rn sb.Append("");rn sb.Append(Epoint.Frame.Common.DateTimeOperate.ConvertToDateTime(Convert.ToString(drv["PubInWebDate"])).ToString("yyyyMMdd"));rn sb.Append("");rn rn sb.Append("");rn sb.Append("");rn //记录发送报文rn WriteSendXml(strCategoryNum + "List", sb.ToString());rn return sb.ToString();rn rnrn [WebMethod]rn public string GetForProvinceContent(string strCheckCode, string strCategoryNum, string strInfoID)rn rn string strReturn = "";rn if (!this.GetChecked(strCheckCode, strCategoryNum))rn rn strReturn = "验证码错误!";rn return strReturn;rn rn DataView dvGG =rn Epoint.MisBizLogic2.DB.ExecuteDataView(rn "select InfoID,InfoContent from view_infomain where InfoID='" + strInfoID + "'");rn StringBuilder sb = new StringBuilder();rn sb.Append("");rn sb.Append("");rn sb.Append("");rn sb.Append("");rn sb.Append(dvGG.Count);rn sb.Append("");rn sb.Append("");rn sb.Append("");rn foreach (DataRowView drv in dvGG)rn rn //公告标识rn sb.Append("");rn sb.Append(Convert.ToString(drv["InfoID"]));rn sb.Append("");rnrn //公告详细内容rn sb.Append("");rn byte[] btyes = System.Text.Encoding.Default.GetBytes(Convert.ToString(drv["InfoContent"]));rn sb.Append(Convert.ToBase64String(btyes));rn sb.Append("");rn rn sb.Append("");rn sb.Append("");rn //记录发送报文rn WriteSendXml(strCategoryNum + "Content", sb.ToString());rn return sb.ToString();rn rnrn //验证rn private bool GetChecked(string strCheckCode, string strCategoryNum)rn rn //strCheckCode为MD5码 栏目号+**$$123rn string strSource = strCategoryNum + "**$$123";rn string strMD5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strSource, "MD5");rnrn if (strMD5 == strCheckCode)rn rn Epoint.Frame.Common.LogOperate.WriteLog(DateTime.Now.ToString() + "公告发送省网校验通过,栏目编号:" + strCategoryNum);rn return true;rn rn Epoint.Frame.Common.LogOperate.WriteLog(DateTime.Now.ToString() + "公告发送省网校验失败,栏目编号:" + strCategoryNum);rn return false;rn rnrn public static void WriteSendXml(string strCategoryNum, string strSendXml)rn rn string strSendXmlDir = "";rn //记录发送报文xmlrn strSendXmlDir = HttpContext.Current.Request.ApplicationPath + "/LogFiles/发送省网公告";rnrn if (!Directory.Exists(strSendXmlDir))rn Directory.CreateDirectory(strSendXmlDir);rn elsern rn strSendXmlDir = strSendXmlDir + "/" + strCategoryNum + "_Send.xml";rn rn System.IO.File.WriteAllText(strSendXmlDir, strSendXml);rn rn rnrn[/code]rn我的java代码[code=java]public static void main(String[] args) throws ServiceException, RemoteException, MalformedURLException, NoSuchAlgorithmException, UnsupportedEncodingException rn final String endpoint = "http://www.sxztb.gov.cn:33556/Ser_Manage_New/GetForProvince.asmx?WSDL";rn String rec_msg = "";rnrn //传的值rn String strCategoryNum = "002007001001";rn String strCheckCode = Md5Util.encode(strCategoryNum + "**$$123").toUpperCase();//32位rn //String strCheckCode = EncoderPwdByMd5(strCategoryNum + "**$$123").toUpperCase(); //64位rn //String strCheckCode = Md5(strCategoryNum + "**$$123").toUpperCase(); //16位rn try rn // 创建一个服务(service)调用(call) rn rn Service service = new Service();rn Call call = (Call) service.createCall();rnrn // 设置service所在URL rn call.setTargetEndpointAddress(new URL(endpoint));rn //call.setEncodingStyle("utf-8");rn rn //设置SOAPActionURIrn call.setSOAPActionURI("http://epoint.com.cn/GetForProvinceList");rn call.setUseSOAPAction(true);rn rn //指定方法名rn call.setOperationName(new QName("http://epoint.com.cn","GetForProvinceList"));rn call.setEncodingStyle("UTF-8");rn //设置参数rn call.addParameter(new QName("http://epoint.com.cn","strCheckCode"), XMLType.XSD_STRING, ParameterMode.IN);rn call.addParameter(new QName("http://epoint.com.cn","strCategoryNum"), XMLType.XSD_STRING, ParameterMode.IN);rn rn //设置返回值类型rn call.setReturnType(XMLType.XSD_STRING);rn rn //远程调用webservice接口rn rn rec_msg = (String)call.invoke( new Object[]strCheckCode,strCategoryNum);rn rn System.out.println("msg result = " + rec_msg);rn System.out.println(strCheckCode+"=="+strCategoryNum);rn catch (ServiceException e) rn e.printStackTrace();rn catch (RemoteException e) rn e.printStackTrace();rn rn [/code]rnrnjava调用webservice接口所传的值,接口无法获取 论坛

java调用C# webservice接口

11-18

如题。rn调用代码:rntry rn String username="123456";rn String password="123456";rn //WebService URLrn String service_url = "http://*.*.*.*:8080/webservice/UserManage.asmx";rn rn Service service = new Service();rn Call call = (Call) service.createCall();rn call.setTargetEndpointAddress(new java.net.URL(service_url));rn rn //设置要调用的方法rn call.setOperationName(new QName("http://temp.org/GetId", "GetId"));rn rn //该方法需要的参数rn call.addParameter("username", org.apache.axis.encoding.XMLType.XSD_STRING,rn javax.xml.rpc.ParameterMode.IN);rn call.addParameter("password", org.apache.axis.encoding.XMLType.XSD_STRING,rn javax.xml.rpc.ParameterMode.IN);rn rn rn //方法的返回值类型rn call.setReturnType(org.apache.axis.encoding.XMLType.XSD_INT);rn call.setUseSOAPAction(true);rn call.setSOAPActionURI("http://temp.org/GetId");rn rn //调用该方法rn// Double res = (Double) call.invoke(new Object[]rn// username,passwordrn// );rn int res = (Integer)call.invoke(rn new Object[]rn username,passwordrn rn );rn rn System.out.println( "Result: " + res);rn rn catch (Exception e)rn e.printStackTrace();rn// System.err.println(e);rn rnrnrn这是我的代码,我取出来的值确是0。但数据库中存在大于0的值。是什么问题造成的呢?请记手解决。rnrnrnrnrnPOST /sqtwebservice/UserManage.asmx HTTP/1.1rnHost: *.*.*.*//IP地址rnContent-Type: text/xml; charset=utf-8rnContent-Length: lengthrnSOAPAction: "http://temp.org/GetId"rnrnrnrn rn rn stringrn stringrn rn rnrn 论坛

没有更多推荐了,返回首页