由.NET客户端构造的SOAP具有有效对象,Java客户端SOAP具有null对象

时间:2012-12-17 12:44:29

标签: java .net soap

我在使用与.NET Web服务通信的Java客户端构建的SOAP时遇到问题。 我还有一个用于测试目的的.NET客户端,使用这个客户端我没有任何问题。

你能帮我找到可能出错的地方吗?

SOAP JAVA

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:exportReferentiel xmlns:ns2="http://www.svad.actoll.com/Svad2BPass/V1.0">
<exportData>
<produit idRechargement="202" libelle="Ticket 10 x 1h individuel" LibelleIhm="Ticket 10x1h ind" ordreTri="10" descriptionLongue="Ticket 10 x 1h individuel" dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00">
    <tarif libelle="202">
    <validiteTarif dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00" valeur="1070" />
    <validiteTarif dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00" valeur="1070" />
    </tarif>
    </produit>
...

上面的SOAP有一个Null对象

.NET SOAP

<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <exportReferentiel xmlns="http://www.svad.actoll.com/Svad2BPass/V1.0">
      <exportData>
        <produit idRechargement="998" libelle="Teste" LibelleIhm="Teste" ordreTri="98" descriptionLongue="batatinhas" dateDebut="2010-05-10T00:00:00" dateFin="2012-12-31T00:00:00" xmlns="">
          <tarif libelle="998">
            <validiteTarif dateDebut="2010-05-10T00:00:00" dateFin="2012-12-31T00:00:00" valeur="300" />
            <validiteTarif dateDebut="2012-12-31T23:59:59.999" dateFin="2013-12-31T00:00:00" valeur="600" />
          </tarif>
        </produit>
...

Web Service .NET

[WebService(Namespace = "http://www.svad.actoll.com/Svad2BPass/V1.0")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service : System.Web.Services.WebService, ISvad2BPass
{
    private static bool Debug = false;
[WebMethod]
    [SoapDocumentMethod("http://www.svad.actoll.com/Svad2BPass/V1.0/exportReferentiel")]
    public ExportPassTransBPassStatusType exportReferentiel(ExportPassTransBPassType exportData)
    {
        Debug = bool.Parse(ConfigurationManager.AppSettings["Debug"]);

        Logger.Instance.Log(LogTypeCode.DEBUG, exportData.ToString());

        exportReferentielRequest req = new exportReferentielRequest(exportData);
        return LoadExportPassTransBPass(req);
    }

使用Java SOAP的exportData变为null,而使用.NET SOAP,所有数据都变得正常......

任何人都可以帮我这个吗?

2 个答案:

答案 0 :(得分:0)

我昨天正在打一个类似的问题。最后发现,合约界面中的参数名称与客户端传递的参数名称不匹配。但是,查看您的请求,我发现Java客户端和.net客户端之间没有任何名称差异。

您的界面是什么样的?

答案 1 :(得分:0)

我通过将ns2添加到exportData标记来解决此问题。 所以这个SOAP的正确构造是:

<ns2:exportReferentiel xmlns:ns2="http://www.svad.actoll.com/Svad2BPass/V1.0">
<ns2:exportData>
 <produit idRechargement="202" libelle="Ticket 10 x 1h individuel" LibelleIhm="Ticket 10x1h ind" ordreTri="10" descriptionLongue="Ticket 10 x 1h individuel" dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00">
  <tarif libelle="202">
   <validiteTarif dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00" valeur="1070" />
   <validiteTarif dateDebut="1999-01-01T00:00:00.000+01:00" dateFin="2099-01-01T00:00:00.000+01:00" valeur="1070" />
  </tarif>
 </produit>
...
</ns2:exportData>
...