- java调用webservice接口
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.rpc/javax.xml.rpc-api -->
<dependency>
<groupId>javax.xml.rpc</groupId>
<artifactId>javax.xml.rpc-api</artifactId>
<version>1.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
</dependency>
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
@Test
public void a13a() throws MalformedURLException, ServiceException, RemoteException {
Call call=(Call)(new Service()).createCall();
call.setTargetEndpointAddress(new URL("http://218.26.234.115:12666/services/interface?"));
call.setOperationName(new QName("namespace","getSydwJson"));
call.setTimeout(30000);
String re=(String)call.invoke(new String[]{"drorg032"});
System.out.println(re);
}
java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton
webService 报aultString: org.xml.sax.SAXException: Bad envelope tag: definitions
- http请求头加Authorization的Bearer Token
Httpclient 请求带Authorization(授权)的REST API 返回JSON数据
在这里插入代码片
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.7.4</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.7.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.7.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.7.4</version>
</dependency>