从服务引用调用Java Web Service不返回任何内容

时间:2012-01-19 16:36:49

标签: c# .net web-services service-reference

我是在Visual Studio中使用服务引用的新手,我正在尝试使用Java Web服务。我已经使用向导添加了服务引用。该向导构建了代理代码并将端点添加到配置文件中。

Java Endpoint将自定义类型作为单个参数。我通过代理对象填充了对象,并在对服务的调用中传递了该对象。但是当我查看响应对象时,所有属性都为null。不会抛出任何错误。注意,当我使用soapUI时,我可以编辑XML并将XML发送到服务并成功获得响应。如果发生错误,我可以查看在soapUI中发回的XML错误消息。

这是调用代码:

static void CallJavaEndPoint()
{
    IFX_ProductInqRq inqRQ = new IFX_ProductInqRq();
    IFX_ProductInqRqCatSvcRq[] CatSvcRqCollection = new IFX_ProductInqRqCatSvcRq[1];
    IFX_ProductInqRqCatSvcRq CatSvcRqItem = new IFX_ProductInqRqCatSvcRq();
    IFX_ProductServiceReference.FX_Product_PortTypeClient proxy = new FX_Product_PortTypeClient();
    IFX_ProductInqRs response;

    // Remove other code for setting properties for brevity 
    CatSvcRqItem.RequestID = "123456";
    CatSvcRqCollection[0] = CatSvcRqItem;
    inqRQ.CatSvcRq = CatSvcRqCollection;

    // reponse just comes back null, no errors
    response = proxy.IFX_CustomerAccountDetailInquiry(inqRQ);
}
来自配置文件的

    <basicHttpBinding>
        <binding name="IFX_Product_Binding" 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="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
        </binding>
        <binding name="IFX_Product_Binding1" 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="https://example.com/EX_IFXProduct/services/Product_SoapPort_1234"
        binding="basicHttpBinding" bindingConfiguration="IFX_Product_Binding"
        contract="IFX_ProductServiceReference.IFX_Product_PortType"
        name="Product_SoapPort_1234" />
</client>

问题:

  1. 我是否正确调用了Java Web服务?
  2. 如何查看返回的XML错误?
  3. 我最好使用Web Reference或WebRequest / HttpWebRequest连接到此Java Web Service吗?

2 个答案:

答案 0 :(得分:1)

您可以使用像Fiddler这样的工具来检查您从代码发送的请求/响应,然后将其与您使用SoapUI发送的成功请求进行比较。

答案 1 :(得分:1)

您需要做的是查看生成的Reference.cs文件。将有一些不同的命名空间属性。使用SoapUI检查响应时,您将找到正确的命名空间。将Reference.cs文件中的所有命名空间引用替换为您在SoapUI响应中找到的命名空间。

当您完成替换命名空间后,您将看到响应现在已经很好地序列化了。

请记住,Reference.cs是一个生成的文件,在更新服务引用时会丢失更改。