我有一个C#Web服务,它返回一个XML,结果将由Delphi 7应用程序使用.通常情况下,如果我有.Net客户端,我会返回一个.Net XmlDocument类,但对于Delphi,我会返回一个字符串.下面是C#Web服务代码:
public String ReturnXML()
{
XmlDocument xmlDoc = GenerateXmlMethod();
String sXmlResult = String.Empty;
if (xmlDoc != null)
{
using (StringWriter oXml = new StringWriter())
{
xmlDoc.Save(oXml);
sXmlResult = oXml.ToString();
}
}
return sXmlResult;
}
Run Code Online (Sandbox Code Playgroud)
在Delphi中,我得到了另外一个问题下面的代码在这里在StachOverflow,和它完美的作品,如果我不得不从磁盘加载XML和XSD,但我需要从内存中加载它.下面是我的Delphi代码:
procedure TfrmTestador.Button3Click(Sender: TObject);
var
XML, XSDL, XSDLDom: Variant;
begin
XSDLDom := CreateOLEObject('MSXML2.DOMDocument.6.0');
try
XSDLDom.async := false;
XSDLDom.load('C:\Temp\XsdFile.xsd');
XSDL := CreateOLEObject('MSXML2.XMLSchemaCache.6.0');
try
XSDL.add('',XSDLDom);
XML := CreateOLEObject('Msxml2.DOMDocument.6.0');
try
XML.validateOnParse := True;
XML.resolveExternals := True;
XML.schemas := XSDL;
XML.load('C:\Temp\XmlFile.xml');
ShowMessage(XML.parseError.reason);
finally
XML := Unassigned; …Run Code Online (Sandbox Code Playgroud) 我已经开发了一个WCF服务,而在Visual Studio 2010中,我可以毫无问题地导入WSDL.在我将其部署到AppFabric之后,我获得了WSDL,但由于某种原因,无法找到WSDL内部引用的几个模式文件.我不知道这是配置问题,还是什么.我尝试在Visual Studio 2010中处理WSDL时遇到的错误如下:
元数据包含无法解析的引用:
'http : //myserver.mydomain.com : 9871/app_deploy/MyAppService.svc?wsdl'.
WSDL文档包含无法解析的链接.
下载"http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc?xsd=xsd0"时出错.
请求失败,HTTP状态为502:代理错误(指定的网络名称不再可用).
元数据包含无法解析的引用:
'http : //myserver.mydomain.com : 9871/app_deploy/MyAppService.svc'.
在http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc上
没有可以接受该消息的端点.这通常是由错误的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在).
远程服务器返回错误:(404)Not Found.
如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用.
该错误是代理错误,因为它通过代理,但错误是因为页面不存在.我试过http://localhost:9871/app_deploy/MyAppService.svc?xsd=xsd0在服务器上访问,但我得到了404.
为什么不找到这些xsd文件?这是部署问题吗?
任何帮助将不胜感激.
我正在UserNamePasswordValidator使用带有basicHttpBinding 的自定义开发WCF服务.但是,此配置仅适用于HTTPS绑定.由于Visual Studio 2010的内置Web服务器不支持https,如何测试我的自定义验证器?我一直收到Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].错误,如果我将clientCredentialType设置为none,则错误消失,但验证器不会被调用.
以下是我的配置.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="ServiceErrorHandler" type="company.application.appserver.implementation.ServiceErrorHandlerBehaviorExtensionElement, AppSoftAppServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<bindings>
<basicHttpBinding>
<binding name="SimpleBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftUpdate">
<endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="AppSoftUpdate" bindingNamespace="http://company.application/update/2011/04"
contract="company.application.appserver.interfaces.IAppSoftUpdate" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="AppSoftUpdateMex" bindingNamespace="http://company.application/update/2011/04"
contract="IMetadataExchange" />
</service>
<service …Run Code Online (Sandbox Code Playgroud) 我从请求中收到以下 JSON:
{
"cdPlayer": 3,
"nmPlayer": "Player Name",
"dtCreate": "2016-08-24T22:53:31.687",
"dtChange": null,
"idStatus": true
}
Run Code Online (Sandbox Code Playgroud)
我想加载转换 dtCreate 和 dtChange 到 TDateTime。如何正确地做到这一点?没有TJSONDateTime可以投射的GetValue。下面是我当前的代码,我将其转换为纯字符串。
procedure TfrmPrincipal.btnInfoClick(Sender: TObject);
var
jsonRoot: TJSONObject;
tokenRequest: TRESTRequest;
tokenResponse: TRESTResponse;
tokenClient: TRESTClient;
tokenAutenticacao: TOAuth2Authenticator;
begin
tokenClient := TRESTClient.Create(nil);
tokenRequest := TRESTRequest.Create(nil);
tokenResponse := TRESTResponse.Create(nil);
tokenAutenticacao := TOAuth2Authenticator.Create(nil);
try
tokenRequest.Client := tokenClient;
tokenRequest.Response := tokenResponse;
tokenRequest.Method := TRESTRequestMethod.rmPUT;
tokenClient.Authenticator := tokenAutenticacao;
tokenAutenticacao.TokenType := TOAuth2TokenType.ttBEARER;
tokenAutenticacao.AccessToken := 'token_string';
tokenClient.BaseURL := 'http://host/url/method';
tokenRequest.Execute;
jsonRoot:= TJSONObject.ParseJSONValue(tokenResponse.JSONText) as TJSONObject;
Memo1.Lines.Add('cdPlayer …Run Code Online (Sandbox Code Playgroud) 我正在尝试部署到运行AppFabric的Windows 2008 R2 64位服务器,该服务连接到Oracle 10gR2数据库.在我的Windows 7 64位上,在Visual Studio 2010中,一切顺利.我第一次开始使用Oracle ODP.NET,在部署时,我开始使用:
System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
File name: 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'
Run Code Online (Sandbox Code Playgroud)
我尝试了很多东西,似乎没有任何工作,因为我非常渴望让这个工作,并且去了OracleClient,尽管它被标记为已弃用,只是为了让它工作,并给我时间.我删除了我安装的所有内容,但只使用运行时选项安装了win64_11gR2_client.zip.但是,我开始得到:
System.DllNotFoundException: Unable to load DLL 'oramts.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Run Code Online (Sandbox Code Playgroud)
所以我重新安装了win64_11gR2_client.zip,添加了Oracle Services for Microsoft Transaction Server组件.但是,每当我调用我的WCF服务时,IIS都会因以下错误而崩溃:
Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: …Run Code Online (Sandbox Code Playgroud) 我正在尝试为在WCF 4上开发的Web服务导入wsdl.它托管在AppFabric上,并且它具有basicHttpEndpoint绑定.
当尝试导入它时,Delphi锁定,并且bds.exe的内存消耗开始上升......它从100 MB到700 MB.大约15秒后,德尔福才崩溃,关闭了自己.没有错误消息.为什么会这样?我怎么能看出什么是错的?我已经能够从相同的服务器导入WCF 4 wsdl,具有相同的绑定,并使用它们,所以我是kinna卡住了.
TKS
我需要访问具有关闭的Shadow DOM的Web组件的DOM,以进行某些Selenium测试。我读过一些参考资料,您可以Element.prototype.attachShadow在文档启动时重写这些参考资料,以将“阴影”从“关闭”更改为“打开”。为此,我创建了一个Chrome扩展程序。以下是我的manifest.json:
{
"name": "SeleniumTesting",
"description": "Extension to open closed Shadow DOM for selenium testing",
"version": "1",
"author": "SeleniumTesting",
"manifest_version": 2,
"permissions": ["downloads", "<all_urls>"],
"content_scripts": [{
"matches": ["http://localhost:5000/*"],
"run_at": "document_start",
"all_frames": true,
"js": ["shadowInject.js"]
}]
}
Run Code Online (Sandbox Code Playgroud)
还有我的shadowInject.js
console.log('test');
Element.prototype._attachShadow = Element.prototype.attachShadow;
Element.prototype.attachShadow = function () {
console.log('attachShadow');
return this._attachShadow( { mode: "open" } );
};
Run Code Online (Sandbox Code Playgroud)
为了对其进行测试,我在ASPNetCore MVC项目中创建了我的组件。以下是我的JavaScript,用于创建自定义组件:
customElements.define('x-element', class extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({
mode: 'closed'
});
this._shadowRoot.innerHTML = `<div class="wrapper"> …Run Code Online (Sandbox Code Playgroud) 我有一个默认的Entity Framework模型,它包含我的产品的所有默认表,并且所有客户都共享.但是,对于某些客户,我有一些仅为该客户存在的自定义表,但它们与默认产品的表相关.我有第二个实体框架模型来保存这些自定义表.
我的问题是如何使用Join创建Linq to Entities查询,以便将默认模型中的实体与自定义模型上的表相关联?我不介意没有从自定义实体到默认模型上的实体的导航属性; 我只需要一种方法来在一个查询中查询两个模型.
以下是代码:
using (ProductEntities oProductDB = new ProductEntities())
{
using (ProductEntitiesCustom oProductCustomDB = new ProductEntitiesCustom())
{
var oConsulta = oProductCustomDB.CTBLCustoms
.Where(CTBLCustoms => CTBLCustoms.IDWOHD >= 12)
.Join(oProductDB.TBLResources,
CTBLCustoms => new
{
CTBLCustoms.IDResource
},
TBLResources => new
{
TBLResources.IDResource
},
(CTBLCustoms, TBLResources) => new
{
IDCustom = CTBLCustoms.IDCustom,
Descricao = CTBLCustoms.Descricao,
IDWOHD = CTBLCustoms.IDWOHD,
IDResource = CTBLCustoms.IDResource,
ResourceCode = TBLResources.Code
});
gvwDados.DataSource = oConsulta;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到一个The specified LINQ expression contains references to queries that are …
这必须很简单,但是我已经搜索了2个小时,却找不到答案。我该如何在Linq to Entities中编写此代码:
SELECT Reg4, Reg5, Reg6
FROM dbo.Table1
WHERE Reg1 = 15
AND Reg2 = ( SELECT MAX(Reg2) FROM dbo.Table2 WHERE Reg1 = 15);
Run Code Online (Sandbox Code Playgroud)
在查询表达式和基于方法的语法中都可以做到吗?
ks
我想运行一个过程来强制行上的行锁,但我不想将结果集返回给客户端,我也不想更新任何东西.以下是过程:
CREATE OR REPLACE PROCEDURE SP_LOCK_Row
(IDRow IN INTEGER)
IS
BEGIN
SELECT *
FROM TBLTable
WHERE IDRow = IDRow
FOR UPDATE;
END;
Run Code Online (Sandbox Code Playgroud)
问题是我不断收到错误:PLS-00428: an INTO clause is expected in this SELECT statement.有没有办法让我锁定行而不必将结果集返回给客户端?SQL Server的等价物是:
CREATE PROCEDURE dbo.SP_LOCK_Row(
@IDRow INT)
AS
SELECT *
FROM dbo.TBLTable WITH (UPDLOCK, ROWLOCK)
WHERE IDRow = @IDRow
Run Code Online (Sandbox Code Playgroud)
TKS
我们强烈考虑在我们的产品中使用Workflow Foundation 4,但必须同时支持SQL Server和Oracle.有谁知道Workflow Foundation 4的Oracle Instance Store提供程序?
我知道我可以使用SQL Server Express,但我们的一些客户使用Oracle,并且不希望有一个SQL Server,甚至是免费的.
TKS
我有一个带有实体框架的 WEB API 2 调用。如果我DateTime从我从数据库中读取的实体中更新一列DateTime.Now,并将其序列化到客户端,DateTime那么我从数据库收到的列有 3 个毫秒数,但是DateTime我在 C# 中更新的列代码有 6 位数字。下面是我的控制器中的 C# 代码:
[Route("{id:long}/updatedatetime", Name = "UpdateDateTimeByID")]
[HttpPost]
[ResponseType(typeof(ClGroup))]
public async Task<IHttpActionResult> UpdateDateTimeByID(int id)
{
ClGroup clGroup = await db.ClGroups.FindAsync(id);
if (clGroup == null)
{
return NotFound();
}
clGroup.DtUpdate = DateTime.Now;
await db.SaveChangesAsync();
var groupReturn = mapper.Map<ClGroupModel>(clGroup);
return Ok(groupReturn);
}
Run Code Online (Sandbox Code Playgroud)
下面是序列化回客户端的 JSON
{
"CdGroup": 1,
"NmGroup": "Grupo 1",
"DcGroup": "Primeiro Grupo",
"DtInsert": "2016-07-03T22:18:52.257",
"DtUpdate": "2016-07-12T13:31:08.2882558",
"IdStatus": true
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让DtUpdate3 位数字序列化?我使用以下配置更改了格式化程序: …
wcf ×4
c# ×3
delphi ×3
oracle ×3
json ×2
web-services ×2
64-bit ×1
appfabric ×1
datetime ×1
delphi-2010 ×1
hosting ×1
iis-7 ×1
javascript ×1
plsql ×1
rest ×1
shadow-dom ×1
wsdl ×1
xml ×1
xsd ×1