- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
您好,我正在通过 WSDL 将 Java Web 服务加载到 Delphi 7。当我从 Delphi 调用 Web 服务时,出现以下错误。我被困在这里没有任何线索。
'Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'XXXXX'. One of '{XXXXX}' is expected
使用 WSDL delphi 生成以下代码。我已经删除了下面代码中的许多方法。
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/protectappws/services/ProtectappwsImpl?wsdl
// Encoding : UTF-8
// Version : 1.0
// (3/5/2016 5:55:17 AM - 1.33.2.5)
// ************************************************************************ //
unit ProtectappwsImpl;
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"
// !:boolean - "http://www.w3.org/2001/XMLSchema"
// !:int - "http://www.w3.org/2001/XMLSchema"
Encrypt = class; { "http://dsws.org/protectappws/" }
Decrypt = class; { "http://dsws.org/protectappws/" }
// ************************************************************************ //
// Namespace : http://dsws.org/protectappws/
// Serializtn: [xoLiteralParam]
// ************************************************************************ //
Encrypt = class(TRemotable)
private
Fusername: WideString;
Fpassword: WideString;
Fkeyname: WideString;
Fkeyiv: WideString;
Ftransformation: WideString;
Fplaintext: WideString;
public
constructor Create; override;
published
property username: WideString read Fusername write Fusername;
property password: WideString read Fpassword write Fpassword;
property keyname: WideString read Fkeyname write Fkeyname;
property keyiv: WideString read Fkeyiv write Fkeyiv;
property transformation: WideString read Ftransformation write Ftransformation;
property plaintext: WideString read Fplaintext write Fplaintext;
end;
EncryptResponse = type WideString; { "http://dsws.org/protectappws/"[L] }
// ************************************************************************ //
// Namespace : http://dsws.org/protectappws/
// Serializtn: [xoLiteralParam]
// ************************************************************************ //
Decrypt = class(TRemotable)
private
Fusername: WideString;
Fpassword: WideString;
Fkeyname: WideString;
Fkeyiv: WideString;
Ftransformation: WideString;
Fciphertext: WideString;
public
constructor Create; override;
published
property username: WideString read Fusername write Fusername;
property password: WideString read Fpassword write Fpassword;
property keyname: WideString read Fkeyname write Fkeyname;
property keyiv: WideString read Fkeyiv write Fkeyiv;
property transformation: WideString read Ftransformation write Ftransformation;
property ciphertext: WideString read Fciphertext write Fciphertext;
end;
DecryptResponse = type WideString; { "http://dsws.org/protectappws/"[L] }
// ************************************************************************ //
// Namespace : http://dsws.org/protectappws/
// soapAction: http://dsws.org/protectappws/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : protectappwsSOAP
// service : protectappws
// port : protectappwsSOAP
// URL : http://localhost/protectappws/services/ProtectappwsImpl
// ************************************************************************ //
protectappws = interface(IInvokable)
['{EAB73212-14C4-1A41-ABFA-F106C8EB9965}']
function Encrypt(const parameters: Encrypt): EncryptResponse; stdcall;
function Decrypt(const parameters: Decrypt): DecryptResponse; stdcall;
end;
function Getprotectappws(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): protectappws;
implementation
function Getprotectappws(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): protectappws;
const
defWSDL = 'http://localhost/protectappws/services/ProtectappwsImpl?wsdl';
defURL = 'http://localhost/protectappws/services/ProtectappwsImpl';
defSvc = 'protectappws';
defPrt = 'protectappwsSOAP';
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 protectappws);
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;
constructor Encrypt.Create;
begin
inherited Create;
FSerializationOptions := [xoLiteralParam];
end;
constructor Decrypt.Create;
begin
inherited Create;
FSerializationOptions := [xoLiteralParam];
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(protectappws), 'http://dsws.org/protectappws/', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(protectappws), 'http://dsws.org/protectappws/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(protectappws), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(protectappws), ioLiteral);
RemClassRegistry.RegisterXSInfo(TypeInfo(EncryptResponse), 'http://dsws.org/protectappws/', 'EncryptResponse');
RemClassRegistry.RegisterXSInfo(TypeInfo(DecryptResponse), 'http://dsws.org/protectappws/', 'DecryptResponse');
RemClassRegistry.RegisterXSClass(Encrypt, 'http://dsws.org/protectappws/', 'Encrypt');
RemClassRegistry.RegisterSerializeOptions(Encrypt, [xoLiteralParam]);
RemClassRegistry.RegisterXSClass(Decrypt, 'http://dsws.org/protectappws/', 'Decrypt');
RemClassRegistry.RegisterSerializeOptions(Decrypt, [xoLiteralParam]);
end.
下面是我调用 Webservice 的 Delphi 7 代码。
unit Client;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ProtectappwsImpl, StdCtrls, Buttons, InvokeRegistry, Rio,
SOAPHTTPClient;
type
TForm1 = class(TForm)
memResponse: TMemo;
memErrors: TMemo;
btnProcess: TBitBtn;
procedure btnProcessClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnProcessClick(Sender: TObject);
var
ECrypt : Encrypt;
objService : protectappws;
wsResponse : WideString;
ProtectApp : protectappws;
begin
memResponse.Lines.Clear;
memErrors.Lines.Clear;
memResponse.Refresh;
memErrors.Refresh;
try
ECrypt := Encrypt.Create;
ECrypt.username := 'kenwhite';
ECrypt.password := 'kenwhite';
ECrypt.keyname := 'MYKEY';
ECrypt.plaintext := 'Hi';
objService := Getprotectappws(True,EmptyStr,nil);
wsResponse := objService.Encrypt(ECrypt);
except
on E: Exception do
begin
showmessage(e.Message);
end;
end;
end;
end.
当我在 delphi 代码之上运行时,出现以下错误
'Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'username'. One of '{username}' is expected
Delphi 正在向 java web 服务发送以下请求
<?xml version="1.0"?>
-<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
-<SOAP-ENV:Body>
-<Encrypt xmlns="http://dsws.org/protectappws/">
<username>kenwhite</username>
<password>kenwhite</password>
<keyname>MYKEY</keyname>
<keyiv/>
<transformation/>
<plaintext>Hi</plaintext>
</Encrypt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但 web 服务正在等待以下请求。
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prot="http://dsws.org/protectappws/"><soapenv:Header/>
<soapenv:Body>
<prot:Encrypt><username>kenwhite</username>
<password>kenwhite</password>
<keyname>MYKEY</keyname>
<!--Optional:-->
<keyiv/>
<!--Optional:-->
<transformation/>
<plaintext>Hi</plaintext>
</prot:Encrypt>
</soapenv:Body>
</soapenv:Envelope>
为什么 delphi 生成的请求和客户端期望的请求不同。
我尝试从下面的代码中删除 ioDocument 并保留 ioLiteral,反之亦然
InvRegistry.RegisterInvokeOptions(TypeInfo(protectappws), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(protectappws), ioLiteral);
Delphi 7 正在使用 SOAP-ENV 生成 soap 请求,java 需要 soapenv。我真的很困惑并坚持这一点。
最佳答案
为了解决这个问题,我修改了 soap 请求。
Delphi 7 中有一个错误,所以它不允许我更改 soap 请求。为了解决这个问题,我下载了 Soapfix从 embarcadero 更改 HTTPRIO 组件的 soap 请求 onbeforeExecute 事件,它开始工作。 :)
在修改请求之前,我们只需要知道 Web 服务期望什么并更改请求。
根据我的请求 XML,我刚刚从 Encrypt 节点中删除了命名空间,它正在运行。
<Encrypt xmlns="http://dsws.org/protectappws/">
我修改后的请求xml
<?xml version="1.0"?>
-<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
-<SOAP-ENV:Body>
-<Encrypt>
<username>kenwhite</username>
<password>kenwhite</password>
<keyname>MYKEY</keyname>
<keyiv/>
<transformation/>
<plaintext>Hi</plaintext>
</Encrypt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
关于java - '解码错误 : cvc-complex-type. 2.4.a : Invalid content was found starting with element 'XXXXX' . 预计 '{XXXXX}' 之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35816348/
我刚刚注意到 align-self 属性的一些值,这是我以前从未见过的。什么是start、end、self-start、self-end,它们与有什么区别>flex-start 和 flex-end?
我见过程序员使用公式 mid = start + (end - start) / 2 而不是使用更简单的公式 mid = (start + end) / 2 用于查找数组或列表中的中间元素。 为什么他
我们已经设置了一个小型 AZURE VM(由 Microsoft 提供的普通 Windows 2012 R2 镜像),其中包含一个轻量级 DEMO 应用程序,该应用程序可以与 SQLExpress 和
我在笔记本电脑上安装了Xampp 3.2.1版,之前MySQL在它上面运行得很好,但突然MySQL停止运行,而阿帕奇和其他公司都在运行。当我点击开始MySQL时,它显示这个错误我使用Windows 1
我希望我能解释清楚。 我有自动生成的代码,我希望用 CSS 覆盖它。 这是我希望覆盖的代码示例: #u1150:hover #u1153-4 p {color: red} 重要提示:此代码中的“u”将
在我的 package.json 中,我有以下脚本 block : "scripts": { "start": "react-scripts start",
https://github.com/lodash/lodash/blob/3.7.0/lodash.src.js#L2781 此代码段 start = start == null 中的 +start
上下文 我一直在阅读有关如何将 TUMBLINGWINDOW 函数与 TIMSTAMP BY 子句一起使用的文档,但似乎找不到有关如何计算包含 TUMBLING WINDOW 和 TIMESTAMP
我正在使用 Grunt 运行 Protractor 端到端测试用例。我有以下三个任务(我使用的是 windows 7 机器) webdriver-stop webdriver-start Protra
我正在创建一个简单的Java程序,它具有在窗口生成器的帮助下构建的GUI。 GUI只包含一个按钮。 单击按钮后,启动一个线程,该线程将无限次打印到随机数,直到再次单击同一按钮将其停止为止。 这是我的代
我一直在摆弄创建一个运行渲染的线程,并且我遇到了这种实现它的方法: Class Main implements Runnable { private Thread thread; private bo
我如何在 StartButton 类中编写一个 touchesBegun 命令,它在场景中调用 start() 任何实例本身? 我知道......可能是 OOP 101。但今天我远远超出了我的范围。
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
我的目标是运行多个进程并保存它们的 ProcessName和 Id供以后使用。这是我的代码 [System.Collections.ArrayList]$startedProcesses = @()
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我想在另一个脚本的 Start() 之前从一个脚本运行 Start()。是否可以?您可以选择脚本的执行顺序吗? 最佳答案 我不太确定 Start() 但您可以配置 Awake 的脚本执行顺序,OnEn
我有一个来自 Unity 文档页面的示例程序,其中包含 IEnumerator Start() ,如下所示,但我想知道如何才能拥有正常的 void Start() > 在同一个脚本中? 我也尝试添加v
正如标题所说,“从机启动”和“从机启动”有什么区别?当我接受DBA面试时,他问了这个问题,我搜索了google但没有找到答案,有人知道吗? 最佳答案 没有区别.. Slave start; 已弃用,现
我有几十个未记录的表,文档说未记录的表在崩溃或不正常关机后会自动截断。 基于此,我需要在数据库启动后检查一些表,看它们是否为“空”并采取一些措施。 简而言之,我需要在数据库启动后立即执行一个过程。 最
我是一名优秀的程序员,十分优秀!