小编Wow*_*wca的帖子

模型在XML POST上始终为null

我目前正致力于系统之间的集成,我决定使用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,我不知道为什么.有人有线索吗?

.net c# http-post asp.net-web-api

43
推荐指数
2
解决办法
3万
查看次数

rpc \\ literal SOAP不支持命名空间.包装元素必须是不合格的

我目前正在与租赁服务提供商进行集成,该服务提供商运行(我假设)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用于用户"前端".

谢谢你的所有答案!

.net c# wcf soap asp.net-web-api

6
推荐指数
1
解决办法
3644
查看次数

标签 统计

.net ×2

asp.net-web-api ×2

c# ×2

http-post ×1

soap ×1

wcf ×1