以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  给别人提供接口,下面代码有错吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=92974)

--  作者:huhu
--  发布时间:2016/11/17 15:11:00
--  给别人提供接口,下面代码有错吗?
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

\' 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
\' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="mywebservices2")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class myWebService2
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetState(ByVal ddh As String, ByVal ddhh As String, ByVal lhbbh As String, ByVal rjbb As String) As String
        Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
        Dim cn As New SqlClient.SqlConnection(cnStr)
        cn.Open()
        Dim cm As New SqlClient.SqlCommand("s elect 数量 from [可用数量表]  where 订单号 =\'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)
        Dim state As String = cm.ExecuteScalar
        cn.Close()
        Return state
    End Function

End Class

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



--  作者:有点青
--  发布时间:2016/11/17 15:25:00
--  

 按照步骤创建webservice

 

https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=c%23%E5%88%9B%E5%BB%BAwebservice&rsv_pq=df8d638700024c62&rsv_t=c0cdEYRJlOQZ5hNtCZ8MoF9UHmvTANi%2FQLPkexUDfG8oSVDUYwpuTmuIZDk&rqlang=cn&rsv_enter=1&rsv_sug2=0&inputT=16&rsv_sug4=20

 


--  作者:huhu
--  发布时间:2016/11/17 16:28:00
--  
我按照这个做的。以前做的可以啊。这次咋就不行了呢。
http://blog.sina.com.cn/s/blog_45eaa01a0102vopl.html

提示
HTTP Error 400. The request hostname is invalid.

--  作者:huhu
--  发布时间:2016/11/17 16:48:00
--  
老大们,帮我看看呗。
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

\' 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
\' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="WebApplication3")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class myWebService2
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetState(ByVal ddh As String, ByVal ddhh As String, ByVal lhbbh As String, ByVal rjbb As String) As String
        Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
        Dim cn As New SqlClient.SqlConnection(cnStr)
        cn.Open()
        Dim cm As New SqlClient.SqlCommand("s elect 数量 from [可用数量表]  where 订单号 =\'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)
        Dim state As String = cm.ExecuteScalar
        cn.Close()
        Return state
    End Function

End Class

--  作者:有点蓝
--  发布时间:2016/11/17 17:56:00
--  
The request hostname is invalid
IIS配置有问题

1楼图片把提示的错误配置项去掉试试

--  作者:有点蓝
--  发布时间:2016/11/17 17:58:00
--  
既然搞不懂什么配置webservice,把你之前没有问题的项目,直接拷贝过来用呗
--  作者:huhu
--  发布时间:2016/11/18 9:18:00
--  
我就是最后把项目copy过来,改了一下se lect代码。还有改了一下端口号8066.然后就出错了。
--  作者:blackzhu
--  发布时间:2016/11/18 10:06:00
--  
 你这个代码是本地连接,是不是本地的iis配置有问题,原来的又是好的.
--  作者:有点青
--  发布时间:2016/11/18 10:09:00
--  

 能否正常访问过一次?

 

 iis的端口号你怎么改的,用默认的端口号能否访问?


--  作者:huhu
--  发布时间:2016/11/18 11:14:00
--  
起了2个webservices服务。之前的可以正常访问。
新增的这个出错,端口号改的和之前是不一样的。提示webconfig出错。
不论是重新做一个还是copy之前的环境,都是出同样的错。