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

推荐订阅源

Project Zero
Project Zero
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
Security Latest
Security Latest
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
C
CERT Recently Published Vulnerability Notes
S
Schneier on Security
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
Hacker News: Ask HN
Hacker News: Ask HN
G
Google Developers Blog
H
Heimdal Security Blog
O
OpenAI News
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LangChain Blog
C
Cisco Blogs
云风的 BLOG
云风的 BLOG
IT之家
IT之家
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Know Your Adversary
Know Your Adversary
博客园 - 聂微东
The Cloudflare Blog
C
Check Point Blog
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
月光博客
月光博客
T
Tor Project blog
T
Threat Research - Cisco Blogs
T
Tailwind CSS Blog
P
Proofpoint News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
About on SuperTechFans
小众软件
小众软件
Cloudbric
Cloudbric
A
Arctic Wolf

博客园 - yongwnet

项目开发文档格式 JAVA反射实例 java.util.Properties类 jQuery调用WebService详解 产品经理的素质 Java中实现鼠标模拟与键盘映射 Win7下轻松注册VS2008 Windows7 下的VPC 浅谈项目管理能力的提升 java多态性详解——父类引用子类对象 Java截取字符串的一些常用处理 java类加载的表现形式 extjs COMBOBOX完成类似GOOGLE搜索框(AUTOCOMPLETE) - yongwnet - 博客园 如何有效的压缩VPC虚拟磁盘 VPC 2007 Console界面消失以及解决方法 - yongwnet JAVA匿名实现多线程 - yongwnet - 博客园 java中list类和vector类的比较 JAVA深克隆
JAVA 调用 .NET编写的WebService - yongwnet
yongwnet · 2011-01-21 · via 博客园 - yongwnet

1..NET编写的WebService源码

代码

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
<SoapDocumentService(RoutingStyle:=SoapServiceRoutingStyle.RequestElement)> _
Public Class Service1
    
Inherits System.Web.Services.WebService<WebMethod()> _
   
Public Function HelloWorld(ByVal para_in1 As StringByVal para_in2 As StringAs String
        
Try
            
Dim s As String = "para_in1:" & para_in1.ToString() & ",para_in2=" & para_in2 & vbCrLf
            My.Computer.FileSystem.WriteAllText(
"c:\ws.txt", s, True)
            
Return s
        
Catch ex As Exception
            My.Computer.FileSystem.WriteAllText(
"c:\ws.txt""ex:" & ex.ToString() & vbCrLf, True)
            
Return ex.ToString()
        
End Try
        
Return "NO"End Function
End Class

2.JAVA调用源码:

代码

import javax.xml.namespace.QName;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;public class myMain2 {/**
     * 
@param args
     
*/
    
public static void main(String[] args) {
        
// TODO 自动生成方法存根
        InvokeWebservice();
    }
    
    
public static void InvokeWebservice()
    {
        
try
        {
            
/**说明:
               
               
http://127.0.0.1:4727/Service1.asmx    表示Dotnet的WebService地址
               
http://tempuri.org/     表示命名空间
               HelloWorld             表示调用的函数名
               para_in1                表示 HelloWorld 函数的第一个参数名
               para_in2                表示 HelloWorld 函数的第二个参数名
               
               另:本源码需要引用三个JAR包(axis.jar, jaxrpc.jar, commons-discovery-0.2.jar);
             * 
*/        
            
            String endpoint 
= "http://127.0.0.1:4727/Service1.asmx";
                
            Service service 
= new Service();
    
            Call call 
= (Call) service.createCall();
    
            call.setTargetEndpointAddress(
new java.net.URL(endpoint));            
                    
            call.addParameter(
new QName("http://tempuri.org/","para_in1"), org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
            call.addParameter(
new QName("http://tempuri.org/","para_in2"), org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
            call.setReturnType(org.apache.axis.Constants.XSD_STRING);
     
            call.setOperationName(
new QName("http://tempuri.org/","HelloWorld"));
            call.setUseSOAPAction(
true);
            call.setSOAPActionURI(
"http://tempuri.org/HelloWorld"); 

            String para_in1 

= "Java_Invoke_DotnetWebservice";
            String para_in2 
= "2011-01-21";
            String s 
= (String)call.invoke(new Object[]{para_in1, para_in2});
    
            System.out.println(
"result is " + s);
            
        }
        
catch (Exception e) 
        {            
            System.err.println(e.toString());
            e.printStackTrace(); 
        }    
    }
    
}

实例下载: Java_Invoke_DotnetWebservice.rar