2012-12-17 48 views
2

我在与.NET Web服务进行通信的Java客户端下构建的SOAP存在问题。 我也有一个用于测试目的的.NET客户端,并且这个客户端我没有任何问题。由.NET客户端构造的SOAP具有有效的对象,Java客户端SOAP具有空对象

你能帮我找出可能是错的吗?

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有一个空对象

.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服务.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); 
    } 

的exportData与Java SOAP beco mes null,而使用.NET SOAP,它可以与所有数据一起...

任何人都可以帮助我解决这个问题吗?

回答

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> 
... 
0

昨天我还在打类似的问题。最后发现合同接口中的参数名称与客户端传递的内容不匹配。然而,看看你的请求,我没有看到Java客户端和.net客户端之间的任何名称差异。

你的界面是什么样的?

+0

[System.CodeDom.Compiler.GeneratedCodeAttribute( “System.ServiceModel”, “4.0.0.0”)] [System.ServiceModel.ServiceContractAttribute(命名空间=“HTTP ://www.svad.actoll.com/Svad2BPass/V1.0“,ConfigurationName =”Svad2BPass“)] public interface ISvad2BPass {System.ServiceModel.OperationContractAttribute(Action =”http://www.svad。 actoll.com/Svad2BPass/V1.0/exportReferentiel“,ReplyAction =”*“)] [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)] ExportPassTransBPassStatusType exportReferentiel(ExportPassTransBPassType exportData); –

+0

你认为这是一个接口问题吗? –

+0

对我来说看起来没问题。必须与参数名称不匹配有所不同。害怕我没有足够的经验去思考它会是什么。 –