1

I write a simple web service in java use NetBeans, a function accept an array of string. Then I use delphi written a web service client and call the function, server always received an empty array.

When I use soapUI to test the web service, it runs normally.

I checked the xml content send by delphi client and compare with soapUI. this is send by delphi client:

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body>
    <helloList xmlns="http://hw.xzq.com/">
      <helloList>line 1</helloList>
    </helloList>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is send by soapUI:

<soapenv:Envelope
   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:hw="http://hw.xzq.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <hw:helloList>
         <!--Zero or more repetitions:-->
         <helloList>?</helloList>
      </hw:helloList>
   </soapenv:Body>
</soapenv:Envelope>

I copied the xml content of delphi client to soapUI, the server received empty array now.

I modified the xml content by change these three lines:

    <hw:helloList xmlns:hw="http://hw.xzq.com/">
      <helloList>line 1</helloList>
    </hw:helloList>

after this, the server received my string array.

SO, I think the problem is delphi client send array content without a prefix namespace. But how to correct this? Thanks for your help!

By the way, comment the line InvRegistry.RegisterInvokeOptions(TypeInfo(HelloWorld), ioDocument); no help.

mjn
  • 36,362
  • 28
  • 176
  • 378
Hawk Xu
  • 11
  • 2
  • Which web service toolkit are you using in NetBeans (JAX-WS, Axis, Axis2, Apache XCF ...)? – mjn Sep 07 '12 at 11:13
  • Which version of Delphi are you using, and have you upgraded the SOAP libraries? For example, I'm using Delphi2005, but with SOAP libraries from Delphi XE2. There are many fixes to SOAP along the way, so your experience will vary greatly from version to version. – Chris Thornton Sep 07 '12 at 12:20
  • SOAP support in Delphi is not one of its highlights imho - If I encounter problems in critical projects, I prefer writing a C# proxy app which talks with the SOAP service on the one side, and exposes a simple HTTP or even file-based interface to the Delphi world – mjn Sep 07 '12 at 12:35
  • There shouldn't need to be a namespace prefix. The Delphi-generated XML puts the tag in the default namespace, which should be fine. Looks to me like the consumer is the one that can't handle namespaces properly, not the producer. – Rob Kennedy Sep 07 '12 at 16:24
  • 1
    @RobKennedy Delphi puts the payload (SOAP body content) explicitly in the `http://hw.xzq.com/` namespace. Maybe the missing header is the reason. – mjn Sep 07 '12 at 17:18
  • Maybe related: http://stackoverflow.com/questions/7024957/delphi-soap-arrays-problem – mjn Sep 07 '12 at 17:21
  • See also https://forums.embarcadero.com/thread.jspa?threadID=56689 for IS_UNBD option – mjn Sep 07 '12 at 17:22
  • I don't took the header is the difference, @Mjn. We're told that when the failing XML is changed to use prefixes, the server accepts it. It should treat both versions of the input equivalently. – Rob Kennedy Sep 07 '12 at 17:27
  • @RobKennedy yes and yes :) Soap:Header is optional – mjn Sep 07 '12 at 17:43
  • this might help. Article From: Jean-Marie Babet To: Hal Burton Subject: Re: Delphi 2010 webservice consumer pass null strings to webservice Newsgroup: embarcadero.public.delphi.webservices http://www.codenewsfast.com/cnf/article/0/permalink.art-ng1920q1634 – Hui Tan Oct 31 '13 at 12:37

2 Answers2

0

I can verify the problem with NetBeans 7.2 / JAX-WS and Delphi 2009:

Maybe newer Delphi versions can handle this (Delphi XE3 maybe anybody)

My Java code:

@WebMethod(operationName = "example")
public void testArray(@WebParam(name = "arr") String[] arr) {

    System.out.println("in web method");

    System.out.println("Array has " + arr.length + " entries");

    for (String s : arr) {
        System.out.println(s);
    }
}

See also: Delphi and Java Integration using Web Services

Community
  • 1
  • 1
mjn
  • 36,362
  • 28
  • 176
  • 378
0

I write web service using NetBeans 7.2 with Metro 2.0 (.NET 3.5/Metro 1.3 compatible), the client written by delphi 7 with Delphi SOAP Runtime and Importer Update (24535) installed.

I think the problem was delphi client generated xml not compatible with the web service.

I guess this may be help, but I don't know how to do same thing in java.

In the Server, to go to the SOAP web module, select the HTTPSoapPascalInvoker
component, and open up the Options property in the Object Inspector. Make sure
the option "soRootRefNodesToBody" is checked.

In the other way, I guess useing "RFC" type for the web service may be help, but RFC type need JAXB and not support java.util.List.

SO, is another way can correct this?

Hawk Xu
  • 11
  • 2