Delphi 2007 isn't generating the XML I want to send to my Java-WS web service - delphi

I have a Java web service to which I've linked from a Delphi 2007 app using the WSDL Importer. Setting it up has been a rocky road but I'm almost there!
I now have the situation where my arrays aren't being serialized in a way that my Java web service can consume. I've written the same app in .Net to test it out (it works fine) and the XML I'm looking to generate looks like this: -
<?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"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities>
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</activities>
<activities>
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However, the XML that Delphi generates is as follows: -
<?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"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service/">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:activity[2]">
<item href="#2"/>
<item href="#3"/>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
<NS2:activity id="2" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</NS2:activity>
<NS2:activity id="3" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</NS2:activity>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Basically, I need Delphi to stop creating activity elements within the activities element and instead just put each ID and Name inside the an activities element (as .Net does and Java seems to expect).
I've buggered about with the InvRegistry.RegisterInvokeOptions and the RemClassRegistry.RegisterSerializeOptions but none of the combinations seem to work. To be honest I'm on the verge of writting my own XML parser for this as it's taking way to long to figure out. However, if anyone has any suggestions on how this should work I'd be very grateful.
Surely somebody out there must have consumed a Java-WS web service via Delphi 2007 before :)
TIA

It seems the XMLDocument component in Delphi 2007 is broken. I've installed the Alcinoe component instead and that works a charm. That was only a week wasted ... grrrr

Related

attaching #Entity annotations to jaxb-generated classes from a wsdl

My goal is to add #Entity annotations to the classes that are generated from a wsdl. I'm using cxf-codegen-plugin's wsdl2java goal, and pointing at a local wsdl file. I can generate all the sources without any problem, but when I try to add a binding file, I'm running into problems.
Here's a segment of the wsdl (the file is CAAudit.wsdl and is in my resources directory):
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audw="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audx="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:qikrsp="urn:us:gov:hhs:acf:qikrsp"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="CAAudit"
>
<wsdl:types>
<xsd:schema targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xsd:import namespace="urn:us:gov:hhs:acf:qikrsp"
schemaLocation="QuickResponse.xsd" />
<xsd:complexType name="NotifyCAAuditRequest" >
<xsd:sequence>
<xsd:element ref="qikrsp:QuickResponse" />
</xsd:sequence>
</xsd:complexType>
....
My first question is I'm really not certain what should go in the binding file. First, I'm pretty sure that I need jaxws bindings to work with the wsdl (the jaxb binding only has the schemaLocation attribute), although I don't need to generate web service classes.
Next, I'm not sure I'm not sure if the introduction of a new xmlns in the schema element will cause problems for an xpath search. I did have problems running it with notepad++'s xpath evaluation.
Also, I'm not sure if the fact that the QuickResponse element (which is the class I want to annotate) is defined by a reference is hindering my efforts. I'm not sure if or how (or where) I would include the referenced xsd file.
Here is one possible binding file (I was just trying to get an #Generated on the class to start with):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="2.1"
>
<jaxws:bindings wsdlLocation="CAAudit.wsdl"
node="/wsdl:definitions/wsdl:types">
<jaxb:bindings node=".//xsd:schema">
<annox:annotate>#javax.annotation.Generated({"JAXWS"})</annox:annotate>
</jaxb:bindings>
</jaxws:bindings>
</jaxb:bindings>
I did not manage to customize schema embedded in WSDL. This are my latest efforts:
https://github.com/highsource/jaxb2-annotate-plugin/blob/master/tests/jaxws/src/main/resources/wsdl-bindings.xjb
What works with WSDLs is attaching customizations via SCD. But SCD does not allow proprietary customization elements (like annotate:*). So that won't help with jaxb2-annotate-plugin.
So the only thing which would probably work is to extract schema from the WSDL into an own file.

Apigee - How to send XML payload using POST method using Apigee API Development Platform

I am supposed to access a a publicly accessible API (https://ABCInsuranceCoreApp.ng.bluemix.net/ABCInsurance/ProductService) using POST method. It accepts an XML Payload of the form
<Customer>
<Age>40</Age>
<Gender>M</Gender>
<Location>IBM</Location>
</Customer>
and returns a list of products. The API works in a REST-Client and tested.
What I have done in the Apigee API Dev Platform is as follows.
Default ProxyEndpoint:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Flows>
<Flow name="default">
<Request>
<Step>
<Name>AssignCustomerData</Name>
</Step>
<Step>
<Name>ExecuteProductService</Name>
</Step>
</Request>
<Response>
<Step>
<Name>ParseProductList</Name>
</Step>
</Response>
</Flow>
</Flows>
<HTTPProxyConnection>
<BasePath>/v1/abcinsproductservice</BasePath>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default"/>
</ProxyEndpoint>
AssignCustomerData is an AssignMessage Policy and it looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AssignCustomerData">
<DisplayName>AssignCustomerData</DisplayName>
<AssignTo createNew="true" type="request">CustomerData</AssignTo>
<Set>
<Payload contentType="text/xml">
<Customer>
<Age>40</Age>
<Gender>M</Gender>
<Location>IBM</Location>
</Customer>
</Payload>
<Verb>POST</Verb>
</Set>
</AssignMessage>
ExecuteProductService is a service callout and it looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ExecuteProductService">
<!-- Send the message we just made to the target, and save the result -->
<Request variable="CustomerData"/>
<Response>ProductList</Response>
<HTTPTargetConnection>
<URL>https://ABCInsuranceCoreApp.ng.bluemix.net/ABCInsurance/ProductService</URL>
</HTTPTargetConnection>
</ServiceCallout>
and ParseProductList is an ExtractVriable Policy which looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="ParseProductList">
<DisplayName>ParseProductList</DisplayName>
<FaultRules/>
<Properties/>
<VariablePrefix>products</VariablePrefix>
<XMLPayload>
<Variable name="name" type="string">
<XPath>//Products/Product[1]/Name</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
I have dilligently followed the samples, however the arrangement does not work. I am confused as to where the error is.
The trace is not working either..
Can you pls help out..
Many thanks in advance
Amitava
I looks like you need to add Source to your ExtractVariables policy, as in:
<Source clearPayload="false">ProductList</Source>
Also, I'm curious why you are doing this with a ServiceCallout (rather than just routing to your target service via a TargetEndpoint)? I don't see a RouteRule in your ProxyEndpoint. Without a RouteRule, you are creating an Echo Server will will simply reflect back whatever comes in. To stop that from happening, you would need to add a RaiseFault policy after your ExtractVariables policy to terminate the call.
Or, perhaps you are just showing us a snippet and there is really more to it?
The way I see it is,
<Step>
<Name>ParseProductList</Name>
</Step>
Should be a Request Step.
So your proxy becomes,
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Flows>
<Flow name="default">
<Request>
<Step>
<Name>AssignCustomerData</Name>
</Step>
<Step>
<Name>ExecuteProductService</Name>
</Step>
<Step>
<Name>ParseProductList</Name>
</Step>
</Request>
<Response/>
</Flow>
</Flows>
<HTTPProxyConnection>
<BasePath>/v1/abcinsproductservice</BasePath>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default"/>
</ProxyEndpoint>

Using Servicestack WSDL with php

I am trying to use ServiceStack to replace WCF for a self hosted service, accessed with a PHP client that forms its messages from on the WSDL.
The WSDL produced by ServiceStack has "part names" called "par" eg:
<wsdl:message name="GetServiceDetailsIn">
<wsdl:part name="par" element="tns:GetServiceDetails" />
</wsdl:message>
Then the SOAP request produced by PHP looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><par/></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
instead of this from the built-in help:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetServiceDetails xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:Shout" />
</soap:Body>
</soap:Envelope>
The PHP client has used a par tag instead of GetServiceDetails and it gets a blank response. Can the "part name" definition can be renamed or removed in ServiceStack?
It seems you can't doing anything about this in ServiceStack and its not designed to work with PHP anyway. However you can get it working if you get PHP to tweak the XML tags with find-and-replace, or XSLTs, before sending it.

soap ui add wsdl problem

I am using Websphere Message Broker to create web services. I have two services and two wsdl. One of them has no issues and I am able to add WSDL through soap ui.
The other webservice's wsdl is getting displayed in IE but not able to add it in soap ui
getting
Error loading [http://localhost:7800/SearchRQ.xsd] Unexpected element: CDATA on line 1, column 1
Here is the difference in wsdl from IE of both the wsdl:
Search:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="SearchRQ.xsd" />
<xsd:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="SearchRS.xsd" />
</xsd:schema>
DescriptiveInfo:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="http://localhost:31961/DescriptiveInfo?xsd=xsd1" />
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="http://localhost:31961/DescriptiveInfo?xsd=xsd2" />
</xsd:schema>
Any idea? Please help me!!!!
I solved the issue. I placed the WSDL in exactly same structure as targetNamespace defined and used targetNamespace in xsd:schema tag similar to wsdl's targetNamespace.

Can the classpath scanning be controlled in Weld?

I was playing with Weld-SE (Java SE) and noticed that if there are a lot of JARs in the classpath, the JVM startup time runs into several seconds.
Isn't there a way to specify/restrict the scan path as a package pattern or path pattern like in Apache Ant or AspectJ?
PS: Registration on Weld forum just does not work - it keeps saying "your password is trivial"
Starting with weld 1.1.0, it is possible according to Weld reference documentation :
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:weld="http://jboss.org/schema/weld/beans"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
<weld:scan>
<weld:exclude name="mypackage.MyClass"/>
</weld:scan>
</beans>
You can with CDI 1.1. The 1st answer works fine, but this snippet works on any provider:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
<scan>
<exclude name="my.cool.package" />
<!-- you can exclude with condition -->
<exclude name="my.cool.package.for.jodatime" />
<if-class-not-available name="org.joda.time.LocalDate"/>
</exclude>
</scan>
</beans>
Good questions, but I don't think it is possible. Each archive is scanned for beans.xml, by spec.

Resources