我目前正致力于系统之间的集成,我决定使用WebApi,但我遇到了一个问题......
假设我有一个模型:
public class TestModel
{
public string Output { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
POST方法是:
public string Post(TestModel model)
{
return model.Output;
}
Run Code Online (Sandbox Code Playgroud)
我使用标题从Fiddler创建一个请求:
User-Agent: Fiddler
Content-Type: "application/xml"
Accept: "application/xml"
Host: localhost:8616
Content-Length: 57
Run Code Online (Sandbox Code Playgroud)
与身体:
<TestModel><Output>Sito</Output></TestModel>
Run Code Online (Sandbox Code Playgroud)
方法中的model参数Post总是如此null,我不知道为什么.有人有线索吗?
我目前正在与租赁服务提供商进行集成,该服务提供商运行(我假设)Java服务.
当我在Visual Studio 2012中添加服务引用时,正确创建引用,我可以调用服务中指定的方法.
当我收到服务的回复时会出现问题.
假设我使用错误的参数调用服务,getCalculation并获得JSON响应JSONException.问题是,Visual Studio抛出异常There was an error reflecting 'JSONException'.并作为InnerException:{"Namespace='http://service.ecommerce.cetelem.hu/' is not supported with rpc\\literal SOAP. The wrapper element has to be unqualified."}
这是web.config代码:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EcommerceServiceImplPortBinding">
<security mode="Transport" />
</binding>
<binding name="EcommerceServiceImplPortBinding1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://ecomdemo.cetelem.hu:443/ecommerce/EcommerceService"
binding="basicHttpBinding" bindingConfiguration="EcommerceServiceImplPortBinding"
contract="CetelemInstallmentsService.EcommerceService" name="EcommerceServiceImplPort" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
如果这有任何帮助,我将WebAPI用于用户"前端".
谢谢你的所有答案!