You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Matthew Denson <md...@dayspring-tech.com> on 2005/01/05 22:10:03 UTC

RE: Problem with Namespace in request envelope

Hi Anne,

Thanks for your response, sorry for the delay. The WSDL is at the bottom
of this response.

I found the solution to my problem and I'm writing this summary for
posterity (and the next guy like me to search the archives).  The client
classes generated by WSDL2Java included
com.c.amsoe.soap.AmsOeSOAPBindingStub with the following method (I've
reduced it for this email).
-------------------------------------------------------
    public com.ctb.amsoe.soap.Address getAddressForAddressId(long
addressId) throws java.rmi.RemoteException {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[3]);
        _call.setUseSOAPAction(true);
 
_call.setSOAPActionURI("wsm:AmsOeService:AmsOe#getAddressForAddressId");
        _call.setEncodingStyle(null);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
Boolean.FALSE);
 
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
);
        _call.setOperationName(new javax.xml.namespace.QName("",
"getAddressForAddressId"));

        setRequestHeaders(_call);
....
-------------------------------------------------------

If I hand edited the line with the call to setOperationName to 
  _call.setOperationName(new
javax.xml.namespace.QName("urn:soap.amsoe.c.com",
"getAddressForAddressId"));
then the client worked fine.

So your email helped me pin down the problem in my WSDL file.   I had
had this in the wsdl file
        <operation name="getAddressForAddressId">
            <soap:operation
soapAction="wsm:AmsOeService:AmsOe#getAddressForAddressId"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
And eventially decoded your response into modifying this section to this
        <operation name="getAddressForAddressId">
            <soap:operation
soapAction="wsm:AmsOeService:AmsOe#getAddressForAddressId"/>
            <input>
                <soap:body use="literal"
namespace="urn:soap.amsoe.c.com"/>
            </input>
            <output>
                <soap:body use="literal"
namespace="urn:soap.amsoe.c.com"/>
            </output>
        </operation>

With this change the ...Stub file was generated with the namespace in
the Qname as I had been hand editing.

Thanks for your help,
Matthew

Here is the final WSDL file
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<definitions
    name="AmsOe"
    targetNamespace="urn:soap.amsoe.c.com"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="urn:soap.amsoe.c.com"
    xmlns:typens="urn:soap.amsoe.c.com"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <types>
        <xsd:schema
            targetNamespace="urn:soap.amsoe.c.com"
            xmlns="http://schemas.xmlsoap.org/wsdl/"
            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
            xmlns:tns="urn:soap.amsoe.c.com"
            xmlns:typens="urn:soap.amsoe.c.com"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            xmlns:xsd="http://www.w3.org/1999/XMLSchema">
            <xsd:complexType name="address">
                <xsd:all>
                    <xsd:element name="uid" type="xsd:long"/>
                    <xsd:element name="parentuid" type="xsd:long"/>
                    <xsd:element name="oeContactType" type="xsd:int"/>
                    <xsd:element name="oePhaseId" type="xsd:long"/>
                    <xsd:element name="description" type="xsd:string"/>
                    <xsd:element name="last" type="xsd:string"/>
                    <xsd:element name="first" type="xsd:string"/>
                    <xsd:element name="email" type="xsd:string"/>
                    <xsd:element name="phone" type="xsd:string"/>
                    <xsd:element name="phoneExt" type="xsd:string"/>
                    <xsd:element name="streetLine1" type="xsd:string"/>
                    <xsd:element name="streetLine2" type="xsd:string"/>
                    <xsd:element name="city" type="xsd:string"/>
                    <xsd:element name="state" type="xsd:string"/>
                    <xsd:element name="country" type="xsd:string"/>
                    <xsd:element name="zipcode" type="xsd:string"/>
                    <xsd:element name="updatedBy" type="xsd:string"/>
                    <xsd:element name="updatedOn" type="xsd:date"/>
                </xsd:all>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name="getAddressForAddressIdRequest">
        <part name="addressId" type="xsd:long"/>
    </message>
    <message name="getAddressResponse">
        <part name="returnAddress" type="tns:address"/>
    </message>
    <portType name="AmsOe">
        <operation name="getAddressForAddressId">
            <input message="tns:getAddressForAddressIdRequest"/>
            <output message="tns:getAddressResponse"/>
        </operation>
    </portType>
    <binding name="AmsOeSOAPBinding" type="tns:AmsOe">
        <soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="getAddressForAddressId">
            <soap:operation
soapAction="wsm:AmsOeService:AmsOe#getAddressForAddressId"/>
            <input>
                <soap:body use="literal"
namespace="urn:soap.amsoe.c.com"/>
            </input>
            <output>
                <soap:body use="literal"
namespace="urn:soap.amsoe.c.com"/>
            </output>
        </operation>
    </binding>
    <service name="AmsOeService">
        <port binding="tns:AmsOeSOAPBinding" name="AMSOE">
            <soap:address
location="http://localhost:8080/axis/services/AMSOE"/>
        </port>
    </service>
</definitions>
-------------------------------------------------------

-----Original Message-----
From: Anne Thomas Manes [mailto:atmanes@gmail.com] 
Sent: Wednesday, 29 December, 2004 12:09
To: axis-user@ws.apache.org
Subject: Re: Problem with Namespace in request envelope


Can you supply us with the WSDL file? 

The SOAP Body element (the message name -- in your case "GetAddressFor
AddressID") is required to be a qualified element. In an rpc-style
message, the namespace qualifier must be defined in the namespace
attribute in the <soap:body> definition in the WSDL binding. In a
document-style message, the namespace qualifier is the target
namespace for the schema that defines the message element.

Anne

On Tue, 28 Dec 2004 12:30:16 -0800, Matthew Denson
<md...@dayspring-tech.com> wrote:
> 
> 
> Hi all, 
> 
> I am using Axis 1.1 final as a client to call a web service
implemented in
> Blue Martini.  I have what appears to be a configuration problem.
When I
> use the stub generated by wsdl2java to call the web service I get a
fault
> from the web service.  My request from TCPMon looks like:
> 
> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 
>  <soapenv:Body> 
>   <getAddressForAddressId> 
>    <addressId xsi:type="xsd:long">21</addressId> 
>   </getAddressForAddressId> 
>  </soapenv:Body> 
> </soapenv:Envelope> 
> 
> (This request works fine when I use the client against a test Axis web
> service.) 
> 
> If I tweak the envelope slightly as below: 
> 
> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 
>  <soapenv:Body> 
>   <m:getAddressForAddressId xmlns:m="urn:soap.amsoe.c.com"> 
>    <addressId xsi:type="xsd:long">21</addressId> 
>   </m:getAddressForAddressId> 
>  </soapenv:Body> 
> </soapenv:Envelope> 
> 
> And send it with a post everything works as it should.  (There is now
a
> namespace on the message name.) 
> 
> SO, my qestion is how do I get the generated stub to produce the
second
> envelope? 
> 
> I've searched all the documentation I can find but don't really know
what to
> look for, sorry.  Thanks for any help. 
> 
> Cheers, 
> Matthew Denson