以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]调用java 的webservices接口  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=92876)

--  作者:huhu
--  发布时间:2016/11/15 16:03:00
--  [求助]调用java 的webservices接口
这是对方给我的webservices接口
http://192.168.1.83:8002/WebService/OMGR?WSDL
返回数据格式:
“{u8OrderNo:000111,u8LineNo :1,productNo:8111,......}”
 
具体可参考
append("{u8OrderNo:"+schd.getOdDetail().getParentOrder().getOrderNo()+","
+"u8LineNo:"+schd.getOdDetail().getU8LineNo()+","
+"productNo:"+schd.getOdDetail().getProductNo()+","
+"productType:"+schd.getOdDetail().getProductType()+","
+"bdMaterialNo:"+schd.getOdDetail().getBdMaterialNo()+","
+"bdMaterialName:"+schd.getOdDetail().getBdMaterialName()+","
+"productionQuantity:"+schd.getProductionQuantity()+","
+"typeDscr:"+schd.getProductionType()+","
+"depName:"+schd.getDepName()+","
+"startDate:"+schd.getStartDate()+","
+"endDate:"+schd.getEndDate()+","
+"activeOSNo:"+schd.getOdDetail().getActiveOSNo()+","
+"remark:"+schd.getRemark()+","
+"swVersion:"+schd.getOdDetail().getSwVersion()
+"}");
上面是对方提供的。我现在如何调用他的接口?我需要在一个文本框输入"工单号-行号“调用他的接口,keydown事件写代码。希望做到解析webservices接口返回的string,然后把接口对应的加入到我的计划表里面。


--  作者:有点蓝
--  发布时间:2016/11/15 16:29:00
--  
参考:http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=40878

http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=74271

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=77195

http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=91386

--  作者:huhu
--  发布时间:2016/11/15 17:03:00
--  
keydown代码这样?
Dim gdhhh As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim msg As String = gdhhh.text
Dim req = System.Net.WebRequest.Create("http://192.168.1.83:8002/WebService/OMGR?WSDL ")
req.Method = "POST"
req.C    
Dim aryBuf As Byte() = Encoding.GetEncoding("UTF-8").GetBytes(msg)
req.ContentLength = aryBuf.Length
Dim writer = req.GetRequestStream()
writer.Write(aryBuf, 0, aryBuf.Length)
writer.Close()
writer.Dispose()
Dim pos = req.GetResponse
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim str As String = reader.ReadToEnd
pos.Close
stm.Close
reader.close

--  作者:有点青
--  发布时间:2016/11/15 17:36:00
--  
调用后是否报错?str能否得到需要的数据?
--  作者:huhu
--  发布时间:2016/11/16 11:34:00
--  
.NET Framework 版本:2.0.50727.7905
Foxtable 版本:2016.7.29.1
错误所在事件:窗口,生产入库,TextBox3,KeyDown
详细错误信息:
远程服务器返回错误: (415) Unsupported Media Type。


If e.KeyCode = keys.enter Then
    Dim gdhhh As WinForm.TextBox = e.Form.Controls("TextBox3")
    Dim msg As String = gdhhh.text
    msgbox(1)
    Dim req = System.Net.WebRequest.Create("http://192.168.1.83:8002/WebService/OMGR?WSDL")
    req.Method = "POST"
    msgbox(2)
    req.C
    msgbox(3)
    Dim aryBuf As Byte() = Encoding.GetEncoding("UTF-8").GetBytes(msg)
    msgbox(4)
    req.ContentLength = aryBuf.Length
    msgbox(5)
    Dim writer = req.GetRequestStream()
    msgbox(6)
    writer.Write(aryBuf, 0, aryBuf.Length)
    msgbox(7)
    writer.Close()
    msgbox(8)
    writer.Dispose()
    msgbox(9)
    Dim pos = req.GetResponse
    msgbox(10)------没有弹出10.
    Dim stm As System.IO.Stream = pos.GetResponseStream()
    Dim reader As New System.IO.StreamReader(stm)
    Dim str As String = reader.ReadToEnd
    pos.Close
    stm.Close
    reader.close
End If
[此贴子已经被作者于2016/11/16 11:45:14编辑过]

--  作者:有点蓝
--  发布时间:2016/11/16 11:54:00
--  
搞一个我们可以测试的接口地址出来。

WSDL类型接口可能无法直接post

--  作者:huhu
--  发布时间:2016/11/16 15:03:00
--  
这个,这个是对外的,看看行不?
http://203.110.175.29:8091/WebService/OMGR?WSDL
--  作者:有点蓝
--  发布时间:2016/11/16 15:26:00
--  

引入vs,生成dll给狐表调用吧,这样方便好多

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:windowsapplication2.zip

 


图片点击可在新窗口打开查看此主题相关图片如下:1.gif
图片点击可在新窗口打开查看

 


图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看


--  作者:huhu
--  发布时间:2016/11/16 17:37:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20161116173342.png
图片点击可在新窗口打开查看
 

VS 添加类的代码。生成了ClassLibrary1。然后ft引用。
Public Class Class1
    Dim web As New ServiceReference1.WebServiceOmgrClient()
    Public Function getScheduleByWorkOrder(ByVal workOrderNo As String, ByVal lineNo As String) As String
        Return web.getScheduleByWorkOrder(workOrderNo, lineNo)
    End Function
End Class

keydown代码:运行出现附件错误。
Dim gdhhh As WinForm.TextBox = e.Form.Controls("TextBox3")
If e.KeyCode = keys.enter Then
    If gdhhh.text.Contains("-") Then
        Dim id As Integer = gdhhh.text.IndexOf("-")
        Dim str1 As String = gdhhh.text.SubString(0,id)
        Dim str2 As String = gdhhh.text.SubString(id + 1)
        Dim dl As new ClassLibrary1.Class1()
        MessageBox.Show(dl.getScheduleByWorkOrder(str1,str2))

    End If
End If

--  作者:有点蓝
--  发布时间:2016/11/16 17:56:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:classlibrary1.zip