axis2 发布服务调用的问题。。。在线等。。。急。。。。。。。。。
--------------------编程问答-------------------- 没有人知道吗?自己顶一下,,。。 --------------------编程问答-------------------- 主要是,我自己写的axis2客户端就可以成功调用,可是远程写的直接调用服务接口的endpointERP的就显示这个错误了。。。另外,我也想问啊,http://localhost:8080/asservice/services/Version?wsdl和http://localhost:8080/asservice/services/Version有什么区别啊。。。为什么前面可以看到wsdl文件,后面就显示The service cannot be found for the endpoint reference (EPR)了啊。。。 --------------------编程问答-------------------- 遇到同样的问题。。楼主解决方法是什么? --------------------编程问答-------------------- 只能说你写的 远程写的直接调用服务接口的endpointERP 不够规范,不满足AXIS2的要求 --------------------编程问答-------------------- demo,你要么? --------------------编程问答-------------------- 在浏览器输入这个地址:http://localhost:8088/bank/services/bankService?wsdl得到以下结果,说明这个webservice是可用的!
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.bank.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://entity.bank.com/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.bank.com">
<wsdl:documentation>bankService</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://entity.bank.com/xsd">
- <xs:complexType name="Bank">
- <xs:sequence>
<xs:element minOccurs="0" name="account" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="balance" nillable="true" type="xs:float" />
<xs:element minOccurs="0" name="bankName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="money" nillable="true" type="xs:float" />
<xs:element minOccurs="0" name="opraStatus" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="prompt" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax22="http://entity.bank.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.bank.com">
<xs:import namespace="http://entity.bank.com/xsd" />
- <xs:element name="transition">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="fromBack" nillable="true" type="ax22:Bank" />
<xs:element minOccurs="0" name="toBank" nillable="true" type="ax22:Bank" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="transitionResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax22:Bank" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="main">
- <xs:complexType>
- <xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="args" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="mainRequest">
<wsdl:part name="parameters" element="ns:main" />
</wsdl:message>
- <wsdl:message name="transitionRequest">
<wsdl:part name="parameters" element="ns:transition" />
</wsdl:message>
- <wsdl:message name="transitionResponse">
<wsdl:part name="parameters" element="ns:transitionResponse" />
</wsdl:message>
- <wsdl:portType name="bankServicePortType">
- <wsdl:operation name="main">
<wsdl:input message="ns:mainRequest" wsaw:Action="urn:main" />
</wsdl:operation>
- <wsdl:operation name="transition">
<wsdl:input message="ns:transitionRequest" wsaw:Action="urn:transition" />
<wsdl:output message="ns:transitionResponse" wsaw:Action="urn:transitionResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="bankServiceSoap11Binding" type="ns:bankServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="main">
<soap:operation soapAction="urn:main" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
</wsdl:operation>
- <wsdl:operation name="transition">
<soap:operation soapAction="urn:transition" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="bankServiceSoap12Binding" type="ns:bankServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="main">
<soap12:operation soapAction="urn:main" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
</wsdl:operation>
- <wsdl:operation name="transition">
<soap12:operation soapAction="urn:transition" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="bankServiceHttpBinding" type="ns:bankServicePortType">
<http:binding verb="POST" />
- <wsdl:operation name="main">
<http:operation location="bankService/main" />
- <wsdl:input>
<mime:content type="text/xml" part="main" />
</wsdl:input>
</wsdl:operation>
- <wsdl:operation name="transition">
<http:operation location="bankService/transition" />
- <wsdl:input>
<mime:content type="text/xml" part="transition" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="transition" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="bankService">
- <wsdl:port name="bankServiceHttpSoap11Endpoint" binding="ns:bankServiceSoap11Binding">
<soap:address location="http://192.168.1.96:8088/bank/services/bankService.bankServiceHttpSoap11Endpoint/" />
</wsdl:port>
- <wsdl:port name="bankServiceHttpSoap12Endpoint" binding="ns:bankServiceSoap12Binding">
<soap12:address location="http://192.168.1.96:8088/bank/services/bankService.bankServiceHttpSoap12Endpoint/" />
</wsdl:port>
- <wsdl:port name="bankServiceHttpEndpoint" binding="ns:bankServiceHttpBinding">
<http:address location="http://192.168.1.96:8088/bank/services/bankService.bankServiceHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
然后在另外一个项目中测试调用:
package com.axis2.test;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import com.axis2.entity.MyBank;
/**
* 调用axis2的webservice
* */
public class TestAxis2 {
private static TestAxis2 bean = new TestAxis2();
private String serviceUrl = "http://localhost:8088/bank/services/bankService";// webservice的url(这个url必须是通的,否则调用失败)
private String nameSpace = "http://service.bank.com";// webservice的命名空间(其实就是协议和包名的倒写)
/**
* @see 调用axis2的webservice
* @param method 发布方的方法名
* @param args 方法中的参数列表
* @return MyBank
* */
@SuppressWarnings("unchecked")
public MyBank useAxis2(String method, Object[] args) {
MyBank bank = null;
RPCServiceClient client=null;
try {
client = new RPCServiceClient();
Options option = client.getOptions();
EndpointReference erf = new EndpointReference(serviceUrl);
option.setTo(erf);
QName name = new QName(nameSpace, method);
Class[] returnTypes = new Class[] { MyBank.class };
Object[] response = client.invokeBlocking(name, args, returnTypes);
bank = (MyBank) response[0];
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
client.cleanupTransport();
} catch (AxisFault e) {
e.printStackTrace();
}
}
return bank;
}
public static void main(String[] args) {
MyBank fromBack = new MyBank();
MyBank toBank = new MyBank();
MyBank bank = bean.useAxis2("transition", new Object[]{ fromBack, toBank });
System.out.println(bank.getPrompt());
}
}
运行完毕,控制台没有出现异常,而且打印我想要的结果,
这说明axis2发布和调用webservice都成功了!
补充:Java , Java EE