WSDL如下:
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:impl="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:intf="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:message name="setCallBackAddrV2Response">
<wsdl:part name="setCallBackAddrV2Return" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrV2Request">
<wsdl:part name="uc" type="xsd:string" />
<wsdl:part name="pw" type="xsd:string" />
<wsdl:part name="rand" type="xsd:string" />
<wsdl:part name="url" type="xsd:string" />
<wsdl:part name="version" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="getRandomResponse">
<wsdl:part name="getRandomReturn" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrRequest">
<wsdl:part name="uc" type="xsd:string" />
<wsdl:part name="pw" type="xsd:string" />
<wsdl:part name="rand" type="xsd:string" />
<wsdl:part name="url" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrResponse">
<wsdl:part name="setCallBackAddrReturn" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getRandomRequest" />
- <wsdl:portType name="Register">
- <wsdl:operation name="getRandom">
<wsdl:input name="getRandomRequest" message="impl:getRandomRequest" />
<wsdl:output name="getRandomResponse" message="impl:getRandomResponse" />
</wsdl:operation>
- <wsdl:operation name="setCallBackAddr" parameterOrder="uc pw rand url">
<wsdl:input name="setCallBackAddrRequest" message="impl:setCallBackAddrRequest" />
<wsdl:output name="setCallBackAddrResponse" message="impl:setCallBackAddrResponse" />
</wsdl:operation>
- <wsdl:operation name="setCallBackAddrV2" parameterOrder="uc pw rand url version">
<wsdl:input name="setCallBackAddrV2Request" message="impl:setCallBackAddrV2Request" />
<wsdl:output name="setCallBackAddrV2Response" message="impl:setCallBackAddrV2Response" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="RegisterSoapBinding" type="impl:Register">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getRandom">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="getRandomRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="getRandomResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="setCallBackAddr">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="setCallBackAddrRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="setCallBackAddrResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="setCallBackAddrV2">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="setCallBackAddrV2Request">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="setCallBackAddrV2Response">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="RegisterService">
- <wsdl:port name="Register" binding="impl:RegisterSoapBinding">
<wsdlsoap:address location="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>客户调如下:
public static String getRandom(){
String rand="";
String registerUrl="http://202.105.212.146:8080/jboss-net/services/Register?wsdl";
Service srv=new Service();
try {
Call call=(Call)srv.createCall();
call.setTargetEndpointAddress(new URL(registerUrl));
call.setSOAPActionURI("http://xml.apache.org/xml-soap");
call.setOperationName(new QName ("http://realization.webservice.uc.fin.huawei.com","getRandom"));
// System.out.println("CallClass+"+call.WSDL_PORT_NAME);
rand=(String) call.invoke(new Object[]{null});
} catch (ServiceException e) {
// TODO Auto-generated catch block
rand+="<Call>="+e.getMessage()+"\r\n";
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
rand+="<URL>="+e.getMessage()+"\r\n";
} catch (RemoteException e) {
// TODO Auto-generated catch block
rand+="<call.invoke>="+e.getMessage()+"\r\n";
}
return rand;
}报的错误:
No such operation 'getRandom'
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:impl="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:intf="http://202.105.212.146:8080/jboss-net/services/Register" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:message name="setCallBackAddrV2Response">
<wsdl:part name="setCallBackAddrV2Return" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrV2Request">
<wsdl:part name="uc" type="xsd:string" />
<wsdl:part name="pw" type="xsd:string" />
<wsdl:part name="rand" type="xsd:string" />
<wsdl:part name="url" type="xsd:string" />
<wsdl:part name="version" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="getRandomResponse">
<wsdl:part name="getRandomReturn" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrRequest">
<wsdl:part name="uc" type="xsd:string" />
<wsdl:part name="pw" type="xsd:string" />
<wsdl:part name="rand" type="xsd:string" />
<wsdl:part name="url" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="setCallBackAddrResponse">
<wsdl:part name="setCallBackAddrReturn" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getRandomRequest" />
- <wsdl:portType name="Register">
- <wsdl:operation name="getRandom">
<wsdl:input name="getRandomRequest" message="impl:getRandomRequest" />
<wsdl:output name="getRandomResponse" message="impl:getRandomResponse" />
</wsdl:operation>
- <wsdl:operation name="setCallBackAddr" parameterOrder="uc pw rand url">
<wsdl:input name="setCallBackAddrRequest" message="impl:setCallBackAddrRequest" />
<wsdl:output name="setCallBackAddrResponse" message="impl:setCallBackAddrResponse" />
</wsdl:operation>
- <wsdl:operation name="setCallBackAddrV2" parameterOrder="uc pw rand url version">
<wsdl:input name="setCallBackAddrV2Request" message="impl:setCallBackAddrV2Request" />
<wsdl:output name="setCallBackAddrV2Response" message="impl:setCallBackAddrV2Response" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="RegisterSoapBinding" type="impl:Register">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getRandom">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="getRandomRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="getRandomResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="setCallBackAddr">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="setCallBackAddrRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="setCallBackAddrResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="setCallBackAddrV2">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="setCallBackAddrV2Request">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://realization.webservice.uc.fin.huawei.com" />
</wsdl:input>
- <wsdl:output name="setCallBackAddrV2Response">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="RegisterService">
- <wsdl:port name="Register" binding="impl:RegisterSoapBinding">
<wsdlsoap:address location="http://202.105.212.146:8080/jboss-net/services/Register" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>客户调如下:
public static String getRandom(){
String rand="";
String registerUrl="http://202.105.212.146:8080/jboss-net/services/Register?wsdl";
Service srv=new Service();
try {
Call call=(Call)srv.createCall();
call.setTargetEndpointAddress(new URL(registerUrl));
call.setSOAPActionURI("http://xml.apache.org/xml-soap");
call.setOperationName(new QName ("http://realization.webservice.uc.fin.huawei.com","getRandom"));
// System.out.println("CallClass+"+call.WSDL_PORT_NAME);
rand=(String) call.invoke(new Object[]{null});
} catch (ServiceException e) {
// TODO Auto-generated catch block
rand+="<Call>="+e.getMessage()+"\r\n";
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
rand+="<URL>="+e.getMessage()+"\r\n";
} catch (RemoteException e) {
// TODO Auto-generated catch block
rand+="<call.invoke>="+e.getMessage()+"\r\n";
}
return rand;
}报的错误:
No such operation 'getRandom'
但用JAVA不会弄,这个wsdl里还有另外一个方法setCallBackAddr,可以调用,但调用getRandom方法却会报错!
rand=(String) call.invoke(new Object[]{null});