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 Michael Robinson <ro...@gaaoc.us> on 2006/03/14 16:42:01 UTC

[Axis2] How to specifiy operation name

I am attempting to create both the service and client for a document
centric web service with each exchange based on a XML Schema instance.

 

I have taken the MTOM examples (mostly the imagetransfer example) and am
trying to from the client load an XML instance (instead of a jpeg) and
then call the service passing the instance as the SOAP body element. I
have this working.... sortof. In the examples the root element of the
XML within the SOAP body matches the operation name so the client finds
the operation and everything is great! Is this the default behavior? It
seems that some of the examples declare a QName but then never use the
variable to set the desired operation which increases my confusion. 

 

How do I specify the remote operation? I have noticed some of the
examples using objects of AxisService and OperationClient. Is this what
I am looking for? I didn't see anything in the documentation thus far
that talks about specifying the remote operation from the client. Did I
miss it? 

 

Is there an example which deals with XML instances? Would it be correct
to assume that a WSDL to go with this type of exchange will need a lot
of hand tuning from what the engine generates by default? I have looked
for examples that exchange xml instances w/ relevant schemas w/ more
customized WSDL but have not been successful in finding any. 

 

Just in case it might help here are the relevant pieces of my project:
(let me know if I forgot any)

 

Relevant Client code: 

 

public OMElement sendFile(String fileName) throws Exception {

                        OMElement payload = createEnvelope(fileName);

                        

                        Options options = new Options();

 
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

                        options.setTo(targetEPR);

                        

                        // enabling MTOM in the client side

 
options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);

 
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

 

                        

                        ServiceClient sender = new ServiceClient();

                        sender.setOptions(options);

                        return sender.sendReceive(payload);

}

 

private OMElement createEnvelope(String fileName) throws Exception {

 

// create the parser 

                        XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(new
FileReader(inputFile));

 

                        // create the builder

                        OMXMLParserWrapper builder =
OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory()
, parser);

 

                        OMElement xmlDocElement =
builder.getDocumentElement();

                        return xmlDocElement;

}

 

Relevant Service code: 

 

            public OMElement childSupportEnforcementFiling(OMElement
element) throws Exception {

 

                        OMXMLParserWrapper builder =
element.getBuilder();

 

                        QName soapHeaderQName = new
QName("http://schemas.xmlsoap.org/soap/envelope/", "Header");

                        SOAPEnvelope envelope = (SOAPEnvelope)
builder.getDocumentElement();

                        SOAPHeader soapHeader = envelope.getHeader();

 

                        Iterator headerIterator =
soapHeader.getChildElements();

 

                        while (headerIterator.hasNext()) {

                                    SOAPHeaderBlock soapHeaderBlock =
(SOAPHeaderBlock) headerIterator.next();

 
System.out.println("soapHeaderBlock.getLocalName() = " +
soapHeaderBlock.getLocalName());

 

                        }

                        System.out.println("Receiving
Element............................. \n");

                        System.out.println("Local Name = " +
element.getLocalName().toString() + "\n");

                        Iterator iter = element.getChildElements();

 

                        int counter = 0;

                        while (iter.hasNext()) {

                                    System.out.println("Printing child
number: " + counter + " \n");

 

                                    OMElement current = (OMElement)
iter.next();

                                    //
System.out.println(current.toString());

                                    String currentText =
current.getText();

 
System.out.println(current.getLocalName().toString());

                                    System.out.println(currentText);

                                    

                                    Iterator testing =
current.getChildElements();

                                    while(testing.hasNext()) {

                                                OMElement foo =
(OMElement) testing.next();

                                                //
System.out.println(current.toString());

                                                String fooText =
foo.getText();

 
System.out.println(foo.getLocalName().toString());

 
System.out.println(fooText);

                                                            

                                    }

 

                        }

 

                        // Create a navigator

........

.....

.....

 

WSDL (I'm thinking it needs some work....): 

 

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions name="DocumentServiceX"

 
targetNamespace="http://schema.gaaoc.us/body/ga/washington/document/cse/
2.0/document-schema.xsd"

 
xmlns:tns="http://schema.gaaoc.us/body/ga/washington/document/cse/2.0/do
cument-schema.xsd"

            xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 

            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

            

            <wsdl:types>

                        <xsd:schema

 
targetNamespace="http://schema.gaaoc.us/body/ga/washington/document/cse/
2.0/document-schema.xsd"

 
xmlns:tns="http://schema.gaaoc.us/body/ga/washington/document/cse/2.0/do
cument-schema.xsd">

                                    <xsd:element
name="childSupportEnforcementFilingRequest">

                                                <xsd:complexType>

 
<xsd:sequence>

 
<xsd:element tns:name="element" tns:type="xsd:anyType" />

 
</xsd:sequence>

                                                </xsd:complexType>

                                    </xsd:element>

                                    <xsd:element
name="childSupportEnforcementFilingResponse">

                                                <xsd:complexType>

 
<xsd:sequence>

 
<xsd:element name="return" type="xsd:anyType" />

 
</xsd:sequence>

                                                </xsd:complexType>

                                    </xsd:element>

                        </xsd:schema>

            </wsdl:types>

            

            <wsdl:message
name="childSupportEnforcementFilingResponseMessage">

                        <wsdl:part name="part1"
element="tns:childSupportEnforcementFilingResponse" />

            </wsdl:message>

            <wsdl:message
name="childSupportEnforcementFilingRequestMessage">

                        <wsdl:part name="part1"
element="tns:childSupportEnforcementFilingRequest" />

            </wsdl:message>

            

            <wsdl:portType name="DocumentServiceXPort">

                        <wsdl:operation
name="childSupportEnforcementFiling">

                                    <wsdl:input
message="tns:childSupportEnforcementFilingRequestMessage"

 
name="childSupportEnforcementFilingRequestMessage" />

                                    <wsdl:output
message="tns:childSupportEnforcementFilingResponseMessage"

 
name="childSupportEnforcementFilingResponseMessage" />

                        </wsdl:operation>

            </wsdl:portType>

            

            <wsdl:binding name="DocumentServiceXBinding"
type="tns:DocumentServiceXPort">

                        <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />

                        <wsdl:operation
name="childSupportEnforcementFiling">

                                    <soap:operation
soapAction="childSupportEnforcementFiling" style="document" />

                                    <wsdl:input>

                                                <soap:body use="literal"
/>

                                    </wsdl:input>

                                    <wsdl:output>

                                                <soap:body use="literal"
/>

                                    </wsdl:output>

                        </wsdl:operation>

            </wsdl:binding>

            <wsdl:service name="DocumentServiceX">

                        <wsdl:port binding="tns:DocumentServiceXBinding"
name="DocumentServiceXPortType">

                                    <soap:address
location="http://localhost:8080/axis2/services/DocumentServiceX" />

                        </wsdl:port>

            </wsdl:service>

</wsdl:definitions>

 

 

Example XML Instance:
http://schema.gaaoc.us/body/ga/washington/document/cse/example-document.
xml

 

XML Schema(s):  

http://schema.gaaoc.us/body/ga/washington/document/cse/document-schema.x
sd

http://schema.gaaoc.us/body/ga/washington/document/cse/extension/extensi
on-schema.xsd

http://schema.gaaoc.us/body/ga/washington/document/cse/jxdm/3.0.2/constr
aint-schema.xsd

 

Thanks!

 

Michael

 

 




-----------------------------------------
This e-mail and any files transmitted with it are intended solely
for the use of the entity or individual(s) to whom they are
addressed and not for reliance upon by unintended recipients.  If
you are not the intended recipient or the person responsible for
delivering the e-mail to the intended recipient be advised that you
have received this e-mail in error and that any use, dissemination,
forwarding, printing, or copying of this e-mail and any files
transmitted are strictly prohibited. If you have received this
e-mail in error please delete the entire email and immediately
notify us by email to the sender or by telephone to the AOC main
office number, (404) 656-5171. Thank you.