我已经学习并阅读了一下,但我不能这样做,所以我发布这个问题。 这是我的绑定配置:
<bindings>
<customBinding>
<binding name="httpSoap12">
<textMessageEncoding messageVersion="Soap12"/>
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="Service.OnOffService">
<host>
<baseAddresses>
<add baseAddress = "http://192.168.0.14:5554/Service/OnOffService" />
</baseAddresses>
</host>
<endpoint address="soap12" binding="customBinding" bindingConfiguration="httpSoap12" contract="Service.IOnOffService">
这是我的合同:
[ServiceContract(Namespace = "http://testeService")]
public interface IOnOffService
{
[OperationContract]
string OnOff(string Usuario);
}
在这里我构建了Envelope以使用此服务:
sEnv = sEnv & "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap- envelope"" xmlns:tem=""http://testeService/"">"
sEnv = sEnv & " <soap:Header xmlns:wsa=""http://www.w3.org/2005/08/addressing"">"
sEnv = sEnv & " <wsa:Action>http://testeService/IOnOffService/OnOff</wsa:Action>"
sEnv = sEnv & " <wsa:To>http://192.168.0.14:5554/Service/OnOffService</wsa:To>"
sEnv = sEnv & " </soap:Header>"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <tem:OnOff>"
sEnv = sEnv & " <tem:Usuario>A</tem:Usuario>"
sEnv = sEnv & " </tem:OnOff>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
问题是,我收到了400错误请求错误....
答案 0 :(得分:0)
我认为你必须在端点上绑定=“basicHttpBinding”。
我项目的App.config。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
另外,您可以查看我的网站关于肥皂,但我的网络是土耳其。那里有代码。 cihanasan.com