日期:2014-05-18  浏览次数:20375 次

手写代码调用webserver
谁可以手写C#代码,调用那个WebService接口,,麻烦写一下好吗,我知道我分不够,

接口是这样
http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx

在google里查过,,查不到,,才在这里发的,,




不要这种调用的

1.在你的项目引用出,右键-》添加服务引用
2.填入接口地址,例如:http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx
3.确定后系统会自动生成一个代理类
4.直接在你的cs代码处调用代理类下的方法

------解决方案--------------------
HTML code

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="要查询的IP"></asp:Label><br />
        <asp:TextBox ID="txtIP" runat="server">127.0.0.1</asp:TextBox>
        <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="查询" /><br />
        <asp:Label ID="sdfsdf" runat="server" Text="结果"></asp:Label><br />
        <asp:TextBox ID="txtResult" runat="server" Height="20px" Width="146px"></asp:TextBox>
    </div>
    </form>
</body>
</html>