Domino中使用Java访问Webservice(三)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xtiawxf/article/details/83838371
在Lotus Designer开发工具中可以使用Java编写Webservice以及访问Webservice。这里只介绍一下如何访问Websercice。(续)

最后在Designer中创建一代理,可以使用java编写代理,也可以使用Lotusscript编写代理,下面以LotusScript编写代理,调用上面编写java类访问Websercive(用java编写代理也可以直接调用Webservice)。
Option Public
Uselsx "*javacon"
Use "WSClient"

Sub Initialize
Dim jError As JavaError
Dim serviceClient As Variant
Dim js As JAVASESSION
Dim jc As JAVACLASS
Dim session As New NotesSession
Dim db As NotesDatabase
On Error Goto catch
sURL = "http://localhost:80/DWSTest.nsf/DatabaseInfoJava"
sSOAPAction = "getUserRolesArray"
username="XXX"
xmlStr = "<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
xmlStr = xmlStr+" xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='"
xmlStr=xmlStr+"http://schemas.xmlsoap.org/soap/envelope/'"
xmlStr=xmlStr+" xmlns:def='http://DefaultNamespace'>"
xmlStr=xmlStr+"<soapenv:Header/>"
xmlStr=xmlStr+"<soapenv:Body>"
xmlStr=xmlStr+"<def:"+sSOAPAction+" soapenv:encodingStyle="
xmlStr=xmlStr+"'http://schemas.xmlsoap.org/soap/encoding/'>"
xmlStr=xmlStr+"<userName xsi:type='xsd:string'>"+username+"</userName>"
xmlStr=xmlStr+"</def:"+sSOAPAction+">"
xmlStr=xmlStr+"</soapenv:Body>"
xmlStr=xmlStr+"</soapenv:Envelope>"
Set js = New JAVASESSION
Set jc = js.GetClass("WebServiceClient")
Set serviceClient = jc.CreateObject
If(serviceClient.openWSDLURL(sURL,sSOAPAction)) Then
rXMLStr = serviceClient.sendSOAPRequest(xmlStr)
Else
Msgbox "Connect fail..."
End If
Msgbox rXMLStr
Exit Sub
catch:
Set jError = js.getLastJavaError()
If jError.errormsg = "" Then
Print "Error - Err - Erl: " & Error & " - " & Err & " - " & Erl
Error 8005, Error
Else
Print "Error - Err - Erl: " & Error & " - " & Err & " - " & Erl
jsError = jError.stackTrace
Print jsError
Error 8005,jError.errormsg
js.ClearJavaError
End If
End Sub

运行上面的代理,即可查看调用Webservice后返回的数据。注,提供准确的Webservice的URL。

调试过程中可以通过SoapUI(最新版SoapUI3.6)测试Webservice接口,查看其调用Webserivce时发送的Soap请求(包括header、body等信息)。
展开阅读全文

急!Dominojava代理访问webservice问题

05-06

我方是windows的测试机,domino版本是6.5。rn对方是UNIX的测试机,提供webservice服务。rnrn现在的情况是,从IE访问webservice 正常,从telnet测试端口也正常。rnrnjava代理中调用webservice服务代码如下,运行到“InputStreamReader in =new InputStreamReader(con.getInputStream(),"UTF-8");”这句时报错:rn2010-05-06 16:59:20 AMgr: Start executing agent 'sendOAFile' in 'SGSOA/gzgd.nsf'rn2010-05-06 16:59:21 Agent printing: 111=========================================================rn2010-05-06 16:59:21 Agent error: java.io.FileNotFoundException: http://10.110.16.181:30001/axis2/services/OuterBomcInterfacern2010-05-06 16:59:21 Agent error: at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:595)rn2010-05-06 16:59:21 Agent error: at EPMSTask.sendOAFile(EPMSTask.java:35)rn2010-05-06 16:59:21 Agent error: at JavaAgent.NotesMain(JavaAgent.java:43)rn2010-05-06 16:59:21 Agent error: at lotus.domino.AgentBase.runNotes(Unknown Source)rn2010-05-06 16:59:21 Agent error: at lotus.domino.NotesThread.run(NotesThread.java:218)rn2010-05-06 16:59:21 Agent printing: 333=========================================================rn2010-05-06 16:59:21 AMgr: Agent 'sendOAFile' in 'SGSOA/gzgd.nsf' completed executionrnrnrnrnrnrnrnrn public static String sendOAFile(String username,String infoxml)rn String result = null;rn tryrn URL uri = new URL("http://10.110.16.181:30001/axis2/services/OuterBomcInterface");rn URLConnection con = uri.openConnection();rn con.setDoOutput(true);rn con.setRequestProperty("Content-Type","text/xml;charset=UTF-8");rn con.setRequestProperty("SOAPAction","");rn OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(),"UTF-8");rn String data = "";rn data += "";rn data += "";rn data += "";rn data += "HL_BOMC";rn data += "HL_OA"; rn data += "20100506000000";rn data += "N";rn data += ""; rn data += ""+infoxml+""; rn data += "";rn data += "";rn data += "";rn rn out.write(data);rn out.flush();rn out.close();rn System.out.println("111=========================================================");rn InputStreamReader in =new InputStreamReader(con.getInputStream(),"UTF-8");rn System.out.println("222=========================================================");rn int c;rn String responseText="";rn while ((c = in.read( )) != -1) rn responseText += (char)c;rn rn in.close();rn result = responseText;rn catch(Exception e)rn e.printStackTrace();rn System.out.println("333=========================================================");rn rn return result;rn 论坛

一个java访问domino的问题

09-29

请问在用java访问domino数据库并取出数据到关系数据库中的时候,为什么种是报错:rnDominoExample.java:30: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrownrn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); rn但是我单独使用(1)或是(2)的代码就没有问题,请问到底是怎么一回事啊,该怎样解决,谢谢rn以下为我的代码:rnrnimport java.io.*;rnimport java.sql.*;rnimport lotus.domino.*;rnrnpublic class DominoExample rn public static void main(String args[])rn rn tryrn rn //(1)rn String host = "192.1.10.10";rn String user = "po"; rn String password = "1234"; rn rn //(2)rn String dbURL = "jdbc:odbc:AccessDb";rn String dbuser = "po";rn String dbpassword = "1234";rn String databasename = "UserInfo";rn rn //rn String name = "";rn String num = "";rn String query="";rn rn //(2)rn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); rn Connection con = DriverManager.getConnection(dbURL,dbuser,dbpassword); rn Statement AccessDb = con.createStatement();rn con.setCatalog(databasename);rn rn //(1)rn Session session = NotesFactory.createSession(host,user,password);rn Database db = session.getDatabase(host,"CommonUse.nsf");rn View vi = db.getView("View");rn Document doc = vi.getFirstDocument();rn rn while (doc!=null)rn name = doc.getItemValueString("U_name"); rn num = doc.getItemValueString("U_num"); rn rn query = "INSERT INTO Java_Msg VALUES ('" + name + "'," + "'" + num + "')";rnrn AccessDb.executeUpdate(query);rn rn doc = vi.getNextDocument(doc);rn rn rn AccessDb.close();rn con.close();rn session.recycle();rn rn rn catch(NotesException e)rn rn System.out.println(e.getClass().getName()+":"+e.text);rn e.printStackTrace();rn rn rnrn 论坛

.net访问JAVAWebService使用SOAP头

08-18

百度到这个rnrnhttp://www.crazycoder.cn/Java/Article42424.htmlrnrnrn我自己写在一个class里rnrnusing System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Text;rnusing System.Xml.Serialization;rnrnnamespace CAMSDBSyncrnrn [System.CodeDom.Compiler.GeneratedCode("System.Xml", "2.0.50727.3053")]rn [System.SerializableAttribute]rn [System.Diagnostics.DebuggerStepThroughAttribute]rn [System.ComponentModel.DesignerCategoryAttribute("code")]rn [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = true)]rn public partial class MySoapHeader : System.Web.Services.Protocols.SoapHeaderrn rn private string tokenValue;rn private System.Xml.XmlAttribute anyAttrField;rnrn [XmlTextAttribute()]rn public string TokenValuern rn get return this.tokenValue; rn set this.tokenValue = value; rn rnrn [System.Xml.Serialization.XmlAnyAttribute()]rn public System.Xml.XmlAttribute AnyAttrrn rn get return this.anyAttrField; rn set this.anyAttrField = value; rn rnrn private MySoapHeader soapHeaderValue;rnrn public MySoapHeader SoapHeaderValuern rn get return this.soapHeaderValue; rn set this.soapHeaderValue = value; rn rnrn [System.Web.Services.Protocols.SoapHeaderAttribute("SoapHeaderValue")]rn public bool verifyWebserviceTestrn rn object results = this.Invoke("verifyWebserviceTest",new object[0]); (这里object有错,提示:a get or set accessor expected)rn return ((bool)(results[0]));rn rn rnrnrnrnrnrn文章中说 rnArcWS.ManDispCmdSessionBeanService ws = ARSSMonSite.ArcWS.ManDispCmdSessionBeanService;rn ArcWS.loginToken soapHeader = ARSSMonSite.ArcWS.loginToken;rn soapHeader.TokenValue = "arsssongguixiang#19990101010101";rn ws.SoapHeaderValue = soapHeader;rnrnrn ws.veryWebserviceTest; rnrn我是通过在程序里Add Service References的方式添加WebServicern取名为TAServiceReferencesrnrn怎样才能达到上面的效果呢?rnloginToken 这东西我没有呀?这是需要java端放出来吗?rn完全不懂~~~~rn请高手赐教rnrn 论坛

关于使用spring访问webservice

11-07

诸位大侠:rn 小弟正在学习利用spring框架里的远程调用机制来访问webservice,其配置参考手册里面的,但出现了如下的问题,请诸位大侠帮忙斧正:rn 1。原系统是部署了axis的,并提供了客户访问包给我调用,但是未公开它的调用接口【假设是IService,其实现类未ServiceImpl】。rn 2。现调用参考了远程访问提供的wsdlDocumentUrl,对应里面的serviceName and portName.【这个放置在配置文件里面】;现在本地编写IService近似的接口【IService是继承于Remote的】ILocalService【它的实现类对应LocalServiceImpl】,使用相同的方法但不抛出RemoteException,这个作为配置文件里面的"serviceInterface",而由于以前的访问不是这种方式,我在它应该有的路径【反编译IService】创建了一个近似的IService,然后在"portInterface"指向它,在配置文件里面我的配置【假设远程访问的总配置赋的id为"webService",而指向本地实现类的id为"client"】则我当前的配置为 省略 rn 3。 但是在测试是否成功访问【我的依据是有没有创建成功该BEAN,如果是则打印做提示】,但是中途报了java.lang.ClassCastException,打印错误堆栈也没有发现更详细的信息,而getErrorMessage 和 getCause均为null.rn 我不知道具体原因是什么:1。spring访问webservice有什么限制,客户端调用和服务端的实现方面应该注意什么【如果使用spring远程调用的方式】 2. 报这种错的原因是什么,请问你们在访问配置的时候是否出现过类似的问题。rn 希望得到诸位大侠包括斑竹的指导、回复!rn jerryscott 论坛

java 访问Webservice 传递对象类型参数

09-11

public void send() throws Exception rn Map mpResult = null; rn // 调用webService 来验证IDrn rn Client client;rn String url = "http://127.0.0.1:8080/GPSAS_WS_SENDMSG/SendMSGWS.ws?wsdl";rn URL u = new URL(url);rn client = new Client(u);rn Object[] results = null;rn client.setUrl("http://127.0.0.1:8080/GPSAS_WS_SENDMSG/SendMSGWS.ws"); rn rn // 实例化参数对象rn SendMSG sengBean = new SendMSG(); rn sengBean.setMobileNumber("1366666666");rn sengBean.setMessageContent("send");rn rn List lst = new ArrayList();rn lst.add(sengBean);rn sengBean.setLstSend(lst);rn rn // 序列化参数对象rn ByteArrayOutputStream ba = out(sengBean);rn rn System.out.println("-------ok----------" + ba);rn results = client.invoke("test", new Object[] ba);rnrn String idCheckResult = results[0].toString();rn System.out.println("-------ok----------" + idCheckResult);rn rn rn /**rn * 序列化rn * @param sendBeanrn * @returnrn * @throws Exceptionrn */rn public ByteArrayOutputStream out(SendMSG sendBean) throws Exception rn ByteArrayOutputStream buf = new ByteArrayOutputStream(); rn //把User对象序列化到一个字节缓存中 rn ObjectOutputStream out =new ObjectOutputStream(buf); rn out.writeObject(sendBean); rn byte[] buffer = buf.toByteArray();rn rn return buf;rn rnrnrn报异常:java.lang.ClassCastExceptionrnrnresults = client.invoke("test", new Object[] ba);rn这里第二个参数应该转为什么类型,如何转换?rn各位大侠请指点 论坛

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