【发布时间】:2016-12-21 09:33:22
【问题描述】:
输入 Xml
<ws:processAcord xmlns:ws="http://ws.plus.predictivelogic.com/">
<arg0>CrlUser</arg0>
<arg1>CrlPass</arg1>
<arg2>Life Scope</arg2>
<arg3 />
</ws:processAcord>
对象类
[XmlRoot(ElementName = "processAcord", Namespace = "http://ws.plus.predictivelogic.com/")]
public class Input
{
//[DataMember]
[XmlElement(ElementName = "arg0")]
public string Arg0 { get; set; }
//[DataMember]
[XmlElement(ElementName = "arg1")]
public string Arg1 { get; set; }
//[DataMember]
[XmlElement(ElementName = "arg2")]
public string Arg2 { get; set; }
//[DataMember]
[XmlElement(ElementName = "arg3")]
public string Arg3 { get; set; }
//[DataMember]
[XmlAttribute(AttributeName = "ws", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Ws { get; set; }
}
服务定义
public UnderWritingOutput Get(Input inputXml)
{
//do stuff
}
我正在尝试从 SOAPUI 调用我的服务,但这会导致序列化问题。调试时,我没有在 Service 中获取任何数据。
我的代码肯定有一些属性声明问题,例如[DataContract] 或任何其他xml 属性。
更新 1:
我已经发布了服务细节,这里是绑定..
<system.serviceModel>
<services>
<service name="ServiceApplication.UnderWritingService" behaviorConfiguration="debug">
<endpoint address="GetUnderWriting" binding="basicHttpBinding" contract="ServiceApplication.IUnderWritingService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:60418/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>
<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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
当我打开soapUI请求时,它会向我显示输入xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ser="http://schemas.datacontract.org/2004/07/ServiceApplication">
<soapenv:Header/>
<soapenv:Body>
<tem:Get>
<!--Optional:-->
<tem:inputXml>
<!--Optional:-->
<ser:Arg0>?</ser:Arg0>
<!--Optional:-->
<ser:Arg1>?</ser:Arg1>
<!--Optional:-->
<ser:Arg2>?</ser:Arg2>
<!--Optional:-->
<ser:Arg3>?</ser:Arg3>
<!--Optional:-->
<ser:Ws>?</ser:Ws>
</tem:inputXml>
</tem:Get>
</soapenv:Body>
</soapenv:Envelope>
IUnderWritingService
[ServiceContract]
public interface IUnderWritingService
{
[OperationContract]
UnderWritingOutput Get(UnderWritingInput inputXml);
}
【问题讨论】:
-
SoapUI 认为您的操作和消息在命名空间
xmlns:tem="http://tempuri.org/"中,而您的第一个 xml 显示不同的命名空间。你想要发生的事情是什么? -
我在这里发布的第一个 XML,应该是我的服务的输入。
-
但是您确实希望它是一个 SOAP 网络服务,对吧?不是带有简单帖子的 REST 服务?