我正在尝试让Java客户端与WCF wshttpbinding WebService进行通信.但我无法这样做.电话会挂起,或者我得到"musunderstoodheader expcetions".
我的Web服务只是默认的Visual Studio生成的"WCF服务库模板".
我的Web服务客户端只是一个空白的IntelliJ项目,使用"添加Web服务客户端"生成相应的存根(指定的Web服务平台是JAX-WS 2.X).
当我将绑定更改为BasicHttpBinding时,一切都完美无瑕.
我尝试过使用WsHttpBinding配置,包括关闭安全性,但我没有成功.
建议?想法?WAXHttpBinding仅部分支持JAX-WS 2.0吗?
以下是我服务的wsdl文件:
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/UploadVideoProtocol" />
</xsd:schema>
</wsdl:types>
-----
<wsdl:definitions>
<wsdl:service name="VideoUpload">
<wsdl:port name="BasicHttpBinding_IVideoUpload" binding="tns:BasicHttpBinding_IVideoUpload">
<soap:address location="http://localhost:3789/VideoUpload.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)
在上面,我可以通过在服务契约和行为中的代码中指定自定义命名空间来更改命名空间.
但我需要更改架构位置中指定的端点地址,
的schemaLocation = "HTTP://本地主机:3789/VideoUpload.svc XSD = xsd0"
我自己定义的端点地址为:
的schemaLocation = "http://myservice.com:8080/VideoUpload.svc?xsd=xsd0"
实现这个目标的步骤是什么?在代码中要提到什么来更改生成的默认端点?有人可以帮我这个吗?
我正在与WCF合作,与第三方公司交换消息.需要在与ebXML规范匹配的信封中发送和接收消息.理想情况下,我希望尽可能多地使用WCF堆栈,并避免使用一种方法来处理它们,因为在这种情况下,这意味着要再次编写WCF的大部分基础结构.
从我最初的研究中可以看出,这将需要我编写自己的自定义绑定,但我很难在MSDN的文档中找到清晰度.
我已经能够找到很多关于每个实现的详细文档,但很少关于如何将它们全部放在一起.在Peiris和Mulder的"Pro WCF"中,我所拥有的书籍似乎也同样关注这些主题.
我的目标是以下内容.
发送和接收的消息必须格式化如下,其中第一个元素的名称是要执行的操作的名称,子元素是请求消息的有效负载,其格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<op:DoSomething xmlns:op="http://my.ebXML.schema.com" xmlns:payload="http://payload.company.com">
<op:AnObject>
<payload:ImportantValue>42</payload:ImportantValue>
</op:AnObject>
</op:DoSomething>
Run Code Online (Sandbox Code Playgroud)
响应将是:
<?xml version="1.0" encoding="UTF-8"?>
<op:AcknowledgementResponse xmlns:op="http://my.ebXML.schema.com" xmlns:payload="http://payload.company.com">
<op:ResponseObject>
<payload:Ok>True</payload:Ok>
</op:ResponseObject>
</op:AcknowledgementResponse>
Run Code Online (Sandbox Code Playgroud)
由于消息都是由XML模式描述的,因此我使用XSD.exe将这些消息转换为强类型对象.有关架构,请参阅https://gist.github.com/740303.请注意,这些是示例模式.我不能在不违反客户保密协议的情况下发布真实的模式(你也不会因为它们庞大而想要我).
我现在希望能够编写服务实现,如下所示:
public class MyEndpoint : IMyEndpoint
{
public AcknowledgementResponse DoSomething(AnObject value)
{
return new AcknowledgementResponse
{
Ok = True;
};
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.
我需要创建一个托管在IIS中的WCF服务,使用http传输并在服务器的内存中保存状态.虽然我知道有状态服务并不是一个好主意,但最后的约束对于使服务与传统客户端一起工作是必要的.
我的第一个想法是asp.net的会话来存储值.我在我的服务中激活了asp.net兼容模式,这使我可以访问HttpContext,但是放在会话对象中的值没有被保存在内存中.我认为这是因为处理会话状态的http模块没有正确配置,但是当我在网上搜索答案时,WCF会话并认为使用它们可能更好.
但是,WCF会话似乎是在文档下面并在服务上放置了一组奇怪的先决条件,而且我无法找到适合我需要的配置:必须在IIS中托管,必须使用http或https传输并且可以不回复Windows身份验证,因为客户端和服务器不属于同一个域.我试图使用wsHttpBinding来实现这一点,我听说过WCF会话需要安全性或可靠的消息,但是: - 使用标准绑定,当服务器不属于同一个域时,它会失败并出现"SecurityNegotiationException调用者没有通过服务"例外验证.这是相当合理的,因为它使用的是Windows安全性.
如果我禁用安全性完成,它将失败并显示"合同需要会话,但绑定'WSHttpBinding'不支持它或未正确配置以支持它."
如果在保持安全性被禁用的同时启用可靠消息,我会收到异常"绑定验证失败,因为WSHttpBinding不支持基于传输安全性的可靠会话(HTTPS).无法打开通道工厂或服务主机.使用消息安全性实现HTTP上安全可靠的消息传递."
我已经尝试启用传输级安全性,但这似乎对生成的错误没有任何影响
有没有可能对我有用的配置?或者我应该回到使用asp.net会话的计划?
我遇到了这个错误,
警告:装配绑定日志记录已关闭.要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1.
注意:程序集绑定失败日志记录会导致一些性能损失.要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog].
一旦我进入fusion文件夹,我找不到EnableLog文件,你能帮我吗?
我正在编写一个只接收来自本地主机的电话的服务.性能很重要,所以我想我会尝试NetNamedPipeBinding而不是NetTcpBinding,看看我是否能看到任何明显的性能提升.
如果客户端在对服务器执行了一个或多个请求之后,在较长时间内处于空闲状态,则下一个请求似乎会因绑定中的某些空闲超时而失败.服务重新启动时也会发生同样的事情.
我需要我的客户端能够在允许的情况下保持连接打开,以避免与设置新连接相关的开销.我还需要能够不时重新启动服务,并让客户端在发现连接已终止时自动重试.
我知道这可以通过NetTcpBinding中的可靠性内容来支持,但是如何在NetNamedPipeBinding中获得相同级别的重新连接可靠性呢?它甚至可能吗?
这个问题在某种程度上是学术性的,因为它不是使用NetNamedPipes的要求,我可以很容易地采用它来使用tcp绑定,但它是一个痒,我真的想要抓它.
我有一个WCF服务,如果我创建服务时没有指定任何绑定或端点(当我通过Visual Studio注册WCF时从App.config中生成的值读取它).
我有一个返回服务引用的简单方法:
return new SmsServiceReference.SmsEngineServiceClient();
Run Code Online (Sandbox Code Playgroud)
这工作正常(因为从配置中读取值).但是,我想在数据库(例如URI)中有一些这些值,并希望这样做:
Binding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress( "my.uri.com/service.svc" );
return new SmsServiceReference.SmsEngineServiceClient(binding,endpointAddress);
Run Code Online (Sandbox Code Playgroud)
这不起作用.当我尝试使用服务引用时,它会抛出异常.
我怀疑这是因为我的App.config有更多信息,其中两条线路没有提供(显然).问题是,如何以编程方式复制以下App.Config值?
这是我App.Config的片段:( URI已被修改以保护无辜者).
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISmsEngineService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.myuri.com/Services/Services.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISmsEngineService"
contract="SmsServiceReference.ISmsEngineService" name="BasicHttpBinding_ISmsEngineService" />
</client>
Run Code Online (Sandbox Code Playgroud)
我创建了一个WCF服务并公开了三个端点,即basicHttpBinding,wsHttpBinding和webHttpBinding.这是我使用WCF进行实验的测试服务.但是,每当我使用.svc文件添加服务引用时,我只获得两个(基本和ws)端点.由于某种原因,似乎没有第三个(webHttpBidning)端点被暴露.
要重现此问题,请创建WCF应用程序项目,删除Service1服务,添加新项>名为TestService的WCF服务,并将配置文件更改为以下内容:
<system.serviceModel>
<services>
<service name="WcfTestService.TestService" behaviorConfiguration="TestServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost/WcfTestService/TestService.svc"/>
</baseAddresses>
</host>
<endpoint address="basic"
binding="basicHttpBinding"
contract="WcfTestService.ITestService" />
<endpoint address="ws"
binding="wsHttpBinding"
contract="WcfTestService.ITestService" />
<endpoint address="web"
binding="webHttpBinding"
contract="WcfTestService.ITestService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
这是ITestService.cs的代码:
[ServiceContract]
public interface ITestService
{
[OperationContract]
[WebInvoke]
Boolean ValidateUser(User user);
}
[DataContract]
public class User
{
[DataMember(Name = "Name")]
public String UserName { get; set; }
[DataMember] …Run Code Online (Sandbox Code Playgroud) 我正在实现一个模块,用于将文件从客户端机器上传到服务器.在服务器端,我正在使用WCF Soap服务.
为了以块的形式上传文件,我已经从Microsoft http://msdn.microsoft.com/en-us/library/aa717050.aspx实现了这个示例.我已经能够在一个简单的场景中使它工作,所以它确实以块的形式上传文件.此分块模块使用WSDualHttpBinding.
我需要实现一个功能来重新上传文件,以防上传过程因上载特定文件而出于任何原因(用户选择,机器关闭等)而停止.
在我的WCF服务中,我有一个方法来处理服务器端的文件写入:
public void UploadFile(RemoteFileInfo request)
{
FileInfo fi = new FileInfo(Path.Combine(Utils.StorePath(), request.FileName));
if (!fi.Directory.Exists)
{
fi.Directory.Create();
}
FileStream file = new FileStream(fi.FullName, FileMode.Create, FileAccess.Write);
int count;
byte[] buffer = new byte[4096];
while ((count = request.FileByteStream.Read(buffer, 0, buffer.Length)) > 0)
{
file.Write(buffer, 0, count);
file.Flush();
}
request.FileByteStream.Close();
file.Position = 0;
file.Close();
if (request.FileByteStream != null)
{
request.FileByteStream.Close();
request.FileByteStream.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
当函数request.FileByteStream.Read(buffer,0,buffer.Length)被消耗时,分块模块正在发送块.
文件流初始化后,文件被锁定(这是初始化文件流进行写入时的正常行为),但我遇到的问题是我在执行发送/接收过程时停止上传过程,然后是频道分块模块使用的文件未被取消,因此文件保持锁定,因为WCF服务仍在等待发送更多数据,直到发送超时到期(超时为1小时,因为我需要上传文件+ 2.5GB).在下一次上传时,如果我尝试上传同一个文件,我会在WCF服务上遇到异常,因为无法再为同一个文件初始化文件流.
我想知道是否有办法避免/删除文件锁,所以在下次运行时我可以重新上传同一个文件,即使前一个文件流已经锁定了文件.
任何帮助都会很感激,谢谢.
我知道这已被问过很多次了,并相信我,我一直在寻找和尝试其中许多下午半天,但仍然无法超越这个.
我正在尝试通过Web服务提交一些表单内容(也可能包含附件),但是当我尝试附加除小文件之外的任何内容时,仍然会收到以下错误.
我的完整错误是:
格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:scChildForm时出错 .InnerException消息是'反序列化MashForms.Models.SCChildrenForm类型的对象时出错.读取XML数据时已超出最大数组长度配额(16384).通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额.第1行,第41713位.'.有关更多详细信息,请参阅InnerException.
无论我多少尝试在WCF服务和Web客户端的web.config中覆盖该值,它仍然会报告为最大错误和随后的错误.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--<httpRuntime maxRequestLength="409600" executionTimeout="300" />-->
</system.web>
<connectionStrings>
<add name="MashFormsContext" connectionString="Data Source=ServerName;Initial Catalog=MashFormsDev;Persist Security Info=True;User ID=UserName;Password=Password" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceTimeouts transactionTimeout="05:05:00" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="2147483647" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!--<serviceMetadata httpsGetEnabled="true"/>-->
<!-- To receive exception …Run Code Online (Sandbox Code Playgroud) wcf ×10
wcf-binding ×10
.net ×5
c# ×3
web-services ×2
ebxml ×1
java ×1
wcf-security ×1
wcf-sessions ×1
xml ×1