You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by eogreen <eo...@yahoo.com> on 2005/04/30 19:49:10 UTC

WSDLToJava-Generated XML Doesn't Work / But Explicit XML Does Work

Greetings,

I would like to ask a fairly concise question to the developers.  I am having
trouble invocating on an endpoint with the XML which is generated by my
WSDLToJava (created from http://mytarget/service?wsdl) emitter-based classes
(returns ClassCastException).  However, I can successfully invoke on the
endpoint if I explicitly define the XML based on specs I have for the endpoint.
 The specs are slightly different from the WSDLToJava-generated XML, although
the overall structure of the WSDLToJava XML is correct.  I know the endpoint
works from running the explicit code and XML below. 


*** THIS EXPLICIT CODE WORKS FINE ***

    String msg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

    msg += "<soap-env:Envelope
xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">";
    msg += "<soap-env:Header></soap-env:Header>";
    msg += "<soap-env:Body
soap-env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
    msg += "<TraceQuery
xmlns=\"http://www.starviewtechnology.com/schema/2.3/data-query\">";
    msg += "<QueryInterval>";
    msg += "<TimeInterval>";
    msg += "<StartTime>2005-04-29T12:50:00</StartTime>";
    msg += "<EndTime>2005-04-29T12:59:00</EndTime>";
    msg += "</TimeInterval>";
    msg += "</QueryInterval>";
    msg += "<QueryContext>";
    msg += "<Equipment>CVD85</Equipment>";
    msg += "</QueryContext>";
    msg += "<IdList>480,1055,1056,1057,1058</IdList>";    
    msg += "</TraceQuery>";
    msg += "</soap-env:Body>";
    msg += "</soap-env:Envelope>";

    String action = "TraceQuery" ;

    InputStream input = new ByteArrayInputStream(msg.getBytes());
    Service service = new Service();
    Call call = (Call) service.createCall();
    SOAPEnvelope env = new SOAPEnvelope(input);

    call.setTargetEndpointAddress(new URL(URL));
    if (action != null) {
        call.setUseSOAPAction(true);
        call.setSOAPActionURI(action);
    }

    System.out.println("Request:\n" + msg);
    env = call.invoke(env);
    System.out.println("Response:\n" + env.toString());   



*** THIS WDSLToJava generated XML DOES NOT WORK ***

    ... 
        webServiceResponse = queryPort.queryTrace(webServiceTraceQuery);
    ...

... WHICH PRODUCES THE FOLLOWING XML:

    <?xml version="1.0" encoding="UTF-8"?>
   <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:Header><
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"></userdefined></soapenv:Header>
   <soapenv:Body>
      <TraceQuery
xmlns="http://www.starviewtechnology.com/schema/2.3/data-query">
         <QueryInterval>
            <TimeInterval>
               <StartTime>2005-04-29T18:12:43.037Z</StartTime>
               <EndTime>2005-04-29T17:12:43.037Z</EndTime>
            </TimeInterval>
         </QueryInterval>
         <QueryContext>
            <Equipment xsi:type="ns1:constraint-value"
xmlns:ns1="http://www.starviewtechnology.com/schema/2.3/data-query">CVD85</Equipment>
         </QueryContext>
         <IdList>480,1055,1056,1057,1058</IdList>
      </TraceQuery>
   </soapenv:Body></soapenv:Envelope>



*** OFFENDING XML LINES ***

By substititing XML lines, one by one, from the WSDLToJava-generated XML into
the explicit code (that works), I can generate errors individually for each of
the follow lines added.

1) msg += "<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\">";

2) msg += "<soapenv:Header><
soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\"
soapenv:mustUnderstand=\"0\"></userdefined></soapenv:Header>";

3) msg += "<soapenv:Body>";    

4) msg += "<Equipment xsi:type=\"ns1:constraint-value\"
xmlns:ns1=\"http://www.starviewtechnology.com/schema/2.3/data-query\">CVD85</Equipment>";


~~~

The question:  Is there is way for me to, while still using the WSDLToJava
classes, explicitly define/tweek these few XML lines which are causing my
problem?

Of course, any info or insight given or time spent addressing my email will be
much appreciated by me.  I can't seem to find, where in the WSDLToJava classes
to change the the offending lines.  Also, I'm not sure why the WSDLToJava
classes would produce XML which doesn't work .. ?

Regards,
Eric Green
Austin, TX

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: WSDLToJava-Generated XML Doesn't Work / But Explicit XML Does Work

Posted by Anne Thomas Manes <at...@gmail.com>.
Could you please provide the WSDL? 

The code generated is determined by the WSDL. If you want to change
the generated message, you should make sure that your WSDL provides an
accurate definition of the expected input message.

One big difference between the explicit and generate messages is that
your explicit message uses SOAP encoding, and the generated message
used literal encoding.If the service requires SOAP encoding, then I
suspect that your WSDL doesn't correspond to the service. Also, how is
the <Equipment> element defined? (what type?) When using literal
encoding, Axis would only specify the type using xsi:type if it is
overriding the predefined type.

Anne

On 4/30/05, eogreen <eo...@yahoo.com> wrote:
> Greetings,
> 
> I would like to ask a fairly concise question to the developers.  I am having
> trouble invocating on an endpoint with the XML which is generated by my
> WSDLToJava (created from http://mytarget/service?wsdl) emitter-based classes
> (returns ClassCastException).  However, I can successfully invoke on the
> endpoint if I explicitly define the XML based on specs I have for the endpoint.
>  The specs are slightly different from the WSDLToJava-generated XML, although
> the overall structure of the WSDLToJava XML is correct.  I know the endpoint
> works from running the explicit code and XML below.
> 
> *** THIS EXPLICIT CODE WORKS FINE ***
> 
>     String msg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
> 
>     msg += "<soap-env:Envelope
> xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">";
>     msg += "<soap-env:Header></soap-env:Header>";
>     msg += "<soap-env:Body
> soap-env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
>     msg += "<TraceQuery
> xmlns=\"http://www.starviewtechnology.com/schema/2.3/data-query\">";
>     msg += "<QueryInterval>";
>     msg += "<TimeInterval>";
>     msg += "<StartTime>2005-04-29T12:50:00</StartTime>";
>     msg += "<EndTime>2005-04-29T12:59:00</EndTime>";
>     msg += "</TimeInterval>";
>     msg += "</QueryInterval>";
>     msg += "<QueryContext>";
>     msg += "<Equipment>CVD85</Equipment>";
>     msg += "</QueryContext>";
>     msg += "<IdList>480,1055,1056,1057,1058</IdList>";
>     msg += "</TraceQuery>";
>     msg += "</soap-env:Body>";
>     msg += "</soap-env:Envelope>";
> 
>     String action = "TraceQuery" ;
> 
>     InputStream input = new ByteArrayInputStream(msg.getBytes());
>     Service service = new Service();
>     Call call = (Call) service.createCall();
>     SOAPEnvelope env = new SOAPEnvelope(input);
> 
>     call.setTargetEndpointAddress(new URL(URL));
>     if (action != null) {
>         call.setUseSOAPAction(true);
>         call.setSOAPActionURI(action);
>     }
> 
>     System.out.println("Request:\n" + msg);
>     env = call.invoke(env);
>     System.out.println("Response:\n" + env.toString());
> 
> *** THIS WDSLToJava generated XML DOES NOT WORK ***
> 
>     ...
>         webServiceResponse = queryPort.queryTrace(webServiceTraceQuery);
>     ...
> 
> ... WHICH PRODUCES THE FOLLOWING XML:
> 
>     <?xml version="1.0" encoding="UTF-8"?>
>    <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:Header><
> soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> soapenv:mustUnderstand="0"></userdefined></soapenv:Header>
>    <soapenv:Body>
>       <TraceQuery
> xmlns="http://www.starviewtechnology.com/schema/2.3/data-query">
>          <QueryInterval>
>             <TimeInterval>
>                <StartTime>2005-04-29T18:12:43.037Z</StartTime>
>                <EndTime>2005-04-29T17:12:43.037Z</EndTime>
>             </TimeInterval>
>          </QueryInterval>
>          <QueryContext>
>             <Equipment xsi:type="ns1:constraint-value"
> xmlns:ns1="http://www.starviewtechnology.com/schema/2.3/data-query">CVD85</Equipment>
>          </QueryContext>
>          <IdList>480,1055,1056,1057,1058</IdList>
>       </TraceQuery>
>    </soapenv:Body></soapenv:Envelope>
> 
> *** OFFENDING XML LINES ***
> 
> By substititing XML lines, one by one, from the WSDLToJava-generated XML into
> the explicit code (that works), I can generate errors individually for each of
> the follow lines added.
> 
> 1) msg += "<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\">";
> 
> 2) msg += "<soapenv:Header><
> soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\"
> soapenv:mustUnderstand=\"0\"></userdefined></soapenv:Header>";
> 
> 3) msg += "<soapenv:Body>";
> 
> 4) msg += "<Equipment xsi:type=\"ns1:constraint-value\"
> xmlns:ns1=\"http://www.starviewtechnology.com/schema/2.3/data-query\">CVD85</Equipment>";
> 
> ~~~
> 
> The question:  Is there is way for me to, while still using the WSDLToJava
> classes, explicitly define/tweek these few XML lines which are causing my
> problem?
> 
> Of course, any info or insight given or time spent addressing my email will be
> much appreciated by me.  I can't seem to find, where in the WSDLToJava classes
> to change the the offending lines.  Also, I'm not sure why the WSDLToJava
> classes would produce XML which doesn't work .. ?
> 
> Regards,
> Eric Green
> Austin, TX
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>