delphi 客户端自动生成了webserive的访问代码
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://223.68.184.9:8084/DAQItem/services/CallUniversalService?wsdl
// Encoding : UTF-8
// Version : 1.0
// (2017-03-22 21:47:58 - 1.33.2.5)
// ************************************************************************ //
unit CallUniversalService1;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Namespace : http://service.rong
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : CallUniversalServiceSoapBinding
// service : CallUniversalServiceService
// port : CallUniversalService
// URL : http://223.68.184.9:8084/DAQItem/services/CallUniversalService
// ************************************************************************ //
CallUniversalService = interface(IInvokable)
['{2D7FAF1F-C142-A89F-21C5-D321BCA855EA}']
function readStringXml(const x: WideString): WideString; stdcall;
end;
function GetCallUniversalService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): CallUniversalService;
implementation
function GetCallUniversalService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): CallUniversalService;
const
defWSDL = 'http://223.68.184.9:8084/DAQItem/services/CallUniversalService?wsdl';
defURL = 'http://223.68.184.9:8084/DAQItem/services/CallUniversalService';
defSvc = 'CallUniversalServiceService';
defPrt = 'CallUniversalService';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as CallUniversalService);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(CallUniversalService), 'http://service.rong', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(CallUniversalService), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(CallUniversalService), ioDocument);
end.
java 调用接口例子:
接口调用示例:
/**调接口测试
* @param args
* @throws AxisFault
*/
public static void main(String[] args) throws AxisFault {
// TODO Auto-generated method stub
// 使用RPC方式调用WebService
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL (目前为测试地址)
EndpointReference targetEPR = new EndpointReference("http://223.68.184.9:8084/DAQItem/services/CallUniversalService");
options.setTo(targetEPR);
// 指定要调用的计算机器中的方法及WSDL文件的命名空间:
QName opAddEntry = new QName("http://service.rong","readStringXml");
// 参数
String xml = "调用接口需要传输的xml参数";
Object[] opAddEntryArgs = new Object[] {xml};
// 调用plus方法并输出该方法的返回值
Class[] classesa = new Class[] {String.class };
String rest=(String) serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs, classesa)[0];
try {
System.out.println(URLDecoder.decode(rest.toString(), "utf-8"));
} catch (UnsupportedEncodingException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}