This is an aspect of XML that was poorly defined until the XML Schema spec.  That spec 
defines an attribute named 'elementFormDefault', which can have values 'qualified' and 
'unqualified'.  With a value of 'unqualified', the XML looks like the Apache SOAP 
payload you show below.  That the MS SOAP service you are working with wants 
namespaces for each element implies that the WSDL for the service contains a schema 
that specifies the 'qualified' form.  (Note: elementFormDefault is commonly used to 
set global behavior, i.e. behavior for all complexTypes in a schema.  I think there is 
also an elementForm attribute that affects behavior for a single complexType.)

In the current nightly build of Apache SOAP, the SOAPContext class has a method

     public void setQualifyElements(boolean qualifyElements)

that allows you to specify whether elements should be qualified.  If you use that code 
base and call this method with a parameter of true, you should be the behavior you 
desire.

    ...
    call.setSOAPMappingRegistry(Smr);
    call.getContext().setQualifyElements(true);
    ...

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "jer ." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 09, 2004 1:19 PM
Subject: Requestparameters 


Hello !

Could someone please explain to me the following ? Please !!!

All the request examples from Apache SOAP use different namespaces for the 
first subelement
to the SOAP body and the parameter elements.

My SOAP request sent to a MS SOAP server failes due to the fact that SOAP 
parameters having another
namespace then the first SOAPbody subelement. Renaming the parameters with 
the prefix "ns1:"
makes the requests work so I know thats where the problem is.

According to the sample requests on the w3c forum
( see. http://www.w3.org/TR/2003/REC-soap12-part0-20030624/#L1165 ) the same 
namespace is used
for all SOAP parameter elements in the same body subelement so from my point 
of view it looks
like Apache SOAP is making non standard requests !?!??

I have even seen some samples of requests from Axis that shows the same 
behavior ?!?

See below how the "Login" element doesn't use the qualified name 
"ns1:Login"....

My request from Apache SOAP
---------------------------

POST http://www.yaddayadday.com/webservices/customer/customer.asmx HTTP/1.0
Host: www.yaddayadday.com:80
Content-Type: text/xml; charset=utf-8
Content-Length: 554
SOAPAction: 
"http://www.yaddayadday.com/webservices/customer/RequestProductList";

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <SOAP-ENV:Body>
    <ns1:RequestProductList 
xmlns:ns1="http://www.yaddayadday.com/webservices/customer"; 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
       <Login xsi:type="xsd:string">USERID</Login>
       <Password xsi:type="xsd:string">PASSWORD</Password>
    </ns1:RequestProductList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


What it should look like ( According to the MS server and me...)
-----------------------------------------------------------------

POST http://www.yaddayadday.com/webservices/customer/customer.asmx HTTP/1.0
Host: www.yaddayadday.com:80
Content-Type: text/xml; charset=utf-8
Content-Length: 554
SOAPAction: 
"http://www.yaddayadday.com/webservices/customer/RequestProductList";

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <SOAP-ENV:Body>
    <ns1:RequestProductList 
xmlns:ns1="http://www.yaddayadday.com/webservices/customer"; 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
       <ns1:Login xsi:type="xsd:string">USERID</ns1:Login>
       <ns1:Password xsi:type="xsd:string">PASSWORD</ns1:Password>
    </ns1:RequestProductList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Below is my code ( that looks like all the samples I found around).
-------------------------------------------------------------------

URL url = new 
URL("http://www.yaddayadday.com/webservices/customer/customer.asmx";);

Call call = new Call();
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setTargetObjectURI("http://www.yaddayadday.com/webservices/customer";);
call.setMethodName("RequestProductList");
call.setSOAPMappingRegistry(Smr);

Vector params = new Vector();

params.add(new Parameter("Login",String.class,"USERID",null) );
params.add(new Parameter("Password",String.class,"PASSWORD",null) );

call.setParams(params);

resp = 
call.invoke(url,"http://www.yaddayadday.com/webservices/customer/RequestProductList";);


Conclusion
----------

So my question is if Apache SOAP is using a non standard implementation or 
if I am doing something wrong
in my code/assumption. Anyone know how to solve this without rewriting the 
SOAP Apache implementation or the service ?

/Thanks, Jer

_________________________________________________________________
Auktioner: Tj�na en hacka p� gamla prylar http://tradera.msn.se


Reply via email to