惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
T
Threatpost
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
PCI Perspectives
PCI Perspectives
T
The Exploit Database - CXSecurity.com
Y
Y Combinator Blog
雷峰网
雷峰网
爱范儿
爱范儿
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
S
Securelist
宝玉的分享
宝玉的分享
L
LangChain Blog
O
OpenAI News
AI
AI
P
Privacy International News Feed
L
LINUX DO - 最新话题
D
DataBreaches.Net
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
M
MIT News - Artificial intelligence
Security Archives - TechRepublic
Security Archives - TechRepublic
月光博客
月光博客
博客园 - 【当耐特】
T
Tailwind CSS Blog
C
Cybersecurity and Infrastructure Security Agency CISA
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
Jina AI
Jina AI
The Last Watchdog
The Last Watchdog
K
Kaspersky official blog
Webroot Blog
Webroot Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog

博客园 - Ansel

如何做到某个网站被访问? 也谈项目经理 项目团队几个发展阶段总结 如何当好一个项目经理(引用) 微创面试归来话感想 .NET框架垃圾回收机制 二分法——查找、排序以及库函数bsearch的用法 关于web.config - Ansel - 博客园 使用C#和MSMQ开发消息处理程序 访问数据库时如何解决并发问题 very nice to have talked with you via phone 压缩ASP.NET中的ViewState 利用程序动态管理Web.config文件 使用ASP.NET Global.asax 文件--基础篇 ASP.NET 2.0 的内部变化 服务器端异步 Web 方法 在 ASP.NET 中支持数据库缓存相关性 关于 .NET Passport 身份验证 用.Net开发Windows服务初探
.Net调用Java的WebService之亲身体验
Ansel · 2005-08-26 · via 博客园 - Ansel

.Net调用Java的WebService之亲身体验

        前几天公司和别的网站合作,对方用Java的WebService给我们做了一个接口,我觉着既然是WebService,不管是用什么语言编写的,在asp.net工程中添加Web引用都应该得到WebService的一个代理类的。
操作步骤:
1.新建一个asp.net Web 应用程序
2.添加web引用,如图


3.在工程中多了一个名叫Web References得目录,代理类就在这里存放着
4.单击工程中的解决方案资源管理器中的显示所有文件,这是就可以看到那个代理类了,名字叫Reference.cs

        上述工作进行得非常顺利,去沏了一杯茶,回来该调用接口了,但是此时意想不到的终于发生了,居然接口没有在代理类中显示出来,这样的话那怎么调用啊,我认为他的WebService肯定是有问题,于是就电话和对方沟通,他们说没有问题,用Java调用是没有问题的,我们都测试过的。我还是郁闷,于是就静下来想了想,觉着他们的WebService不是标准的WebService,于是又给他们打电话,要求他们把程序检查一下,看是不是标准的WebService,于是他们不耐烦地检查了一下程序,问题终于出现了,就是他们的WebService写的不是很标准的,但是哪儿的问题我没有过问。

        把刚才的删除,又重新添加了一遍Web引用,这时,再看生成的代理类,OK,接口全部有了。

        这里把生成的代理类代码给大家贴出来:

//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.573
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

// 
// 此源代码是由 Microsoft.VSDesigner 1.1.4322.573 版自动生成。

// 
namespace JavaWebService {
    
using System.Diagnostics;
    
using System.Xml.Serialization;
    
using System;
    
using System.Web.Services.Protocols;
    
using System.ComponentModel;
    
using System.Web.Services;
    
    
    
/// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute(
"code")]
    [System.Web.Services.WebServiceBindingAttribute(Name
="VChargeBinding", Namespace="http://csdfsn.esfig/javaservice")]
    
public class VChargeService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        
/// <remarks/>
        public VChargeService() {
            
this.Url = "https://www.csdfsn.cn/cma/javaService?wsdl";
        }

        
        
/// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://csdfsn.esfig/javaservice", ResponseNamespace="http://csdfsn.esfig/javaservice")]
        [
return: System.Xml.Serialization.SoapElementAttribute("result")]
        
public string doservice(string String_1) {
            
object[] results = this.Invoke("doservice"new object[] {
                        String_1}
);
            
return ((string)(results[0]));
        }

        
        
/// <remarks/>
        public System.IAsyncResult Begindovcharge(string String_1, System.AsyncCallback callback, object asyncState) {
            
return this.BeginInvoke("doservice"new object[] {
                        String_1}
, callback, asyncState);
        }

        
        
/// <remarks/>
        public string Enddoservice(System.IAsyncResult asyncResult) {
            
object[] results = this.EndInvoke(asyncResult);
            
return ((string)(results[0]));
        }

        
        
/// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://csdfsn.esfig/javaservice", ResponseNamespace="http://csdfsn.esfig/javaservice")]
        [
return: System.Xml.Serialization.SoapElementAttribute("result")]
        
public string docheck(string String_1) {
            
object[] results = this.Invoke("docheck"new object[] {
                        String_1}
);
            
return ((string)(results[0]));
        }

        
        
/// <remarks/>
        public System.IAsyncResult Begindocheck(string String_1, System.AsyncCallback callback, object asyncState) {
            
return this.BeginInvoke("docheck"new object[] {
                        String_1}
, callback, asyncState);
        }

        
        
/// <remarks/>
        public string Enddocheck(System.IAsyncResult asyncResult) {
            
object[] results = this.EndInvoke(asyncResult);
            
return ((string)(results[0]));
        }

    }

}

        可以看到,这个代理类和引用.net的WebService生成的代理类没有什么区别,此时下面的工作就和用.Net的WebService就一样了

        在此说明一下生成代理类还可以使用其它的方法,如wsdl等,最后的结果都是一样的。