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 Pedro Silva <ps...@dcc.online.pt> on 2006/02/23 01:25:27 UTC

Problem with XML QName when sending it to a webservice

Hi everybody!


I'm trying to build some XML document and send it on the fly to a
webservice. I've managed to do this with a file using the parse method
from javax.xml.parsers, But now I'm tryning to do it building my own XML
doc.

If I print the document I built everything looks ok, but when I invoke
the service I get:

xisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode:
 faultString: Couldn't find an appropriate operation for XML QName
{http://adaptor}itemcount
 faultActor:
 faultNode:
 faultDetail:
	{http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net

Couldn't find an appropriate operation for XML QName
{http://adaptor}itemcount
	at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
	at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
...........


This is the code I'm using to build the XML ands send it. I just can't
figure waht is wrong...

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document db = dbf.newDocumentBuilder();
Document document = db.newDocument();
Element docRoot=document.createElement("itemcount");
document.appendChild(docRoot);
Element itemElem = document.createElement("item");
itemElem.setAttribute("userid",userId);
itemElem.setAttribute("itemid",itemId);
docRoot.appendChild(document.createTextNode("\n"));
docRoot.appendChild(itemElem);
docRoot.appendChild(document.createTextNode("\n"));

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
call.setOperationName(new QName("incrementUserItemCount"));
SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
System.out.println(document.getDocumentElement());
System.out.println(soapInput[0]);
call.invoke(soapInput);


The simple XML doc I'm sending looks like this:
<itemcount>
<item itemid="geral" userid=""/>
</itemcount>

Thanks in advance!
Pedro Silva




Re: Problem with XML QName when sending it to a webservice

Posted by Anne Thomas Manes <at...@gmail.com>.
When using the messaging API, you must create the entire document that goes
into the SOAP Body, not just the parameters. According to your WSDL, the
child element of the SOAP Body must be <tns1:incrementUserItemCount>,
therefore that should be the root element of your document.

Anne

On 2/22/06, Pedro Silva <ps...@dcc.online.pt> wrote:
>
> This a more detailed and accurate piece of my code and error.
> Just so that everybody understands what I'm trying to do is for the
> client to pass to my service some initializations parameters.
>
> Pedro
>
> *My Client Function*
> private void setSOAPDefaultSetttings() throws Exception {
> Document document = db.newDocument();
> Element docRoot = document.createElement("config");
> document.appendChild(docRoot);
> Element itemElem = document.createElement("datadir");
> itemElem.setAttribute("value",dataDir);
> docRoot.appendChild(document.createTextNode("\n"));
> docRoot.appendChild(itemElem);
> docRoot.appendChild(document.createTextNode("\n"));
>
> Service service = new Service();
> Call call = (Call) service.createCall();
>
> call.setTargetEndpointAddress(new
> URL("http://localhost:8080"+webServiceURL));
>         call.setOperationName(new QName("setServiceSettings"));
>
> SOAPBodyElement[] input = new SOAPBodyElement[1];
> input[0] = new SOAPBodyElement(document.getDocumentElement());
> Vector elems = (Vector) call.invoke(input);
> }
>
> *My Service*
> public Element[] setServiceSettings(Element[] sbe) {
> NodeList nl = sbe[0].getElementsByTagName("datadir");
> NamedNodeMap attrs = nl.item(0).getAttributes();
> for (int i = 0; i < attrs.getLength(); i++) {
>   if ("value".equals(attrs.item(i))) {
>    data.AdaptData.setDataDir(attrs.item(i).getNodeValue());
>   }
> }
> Element[] elems = new Element[1];
> elems[0] = null;
> return elems;
> }
>
> *The Error*
> AxisFault
> faultCode:
> {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
> faultSubcode:
> faultString: Couldn't find an appropriate operation for XML QName config
> faultActor:
> faultNode:
> faultDetail:
>         {http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
>
> Couldn't find an appropriate operation for XML QName config
>         at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java
> :222)
> [....]
>
> *My WSDD*
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
> <service name="Adaptor" provider="java:MSG">
>   <parameter name="className" value="adaptor.Adaptor"/>
>   <parameter name="allowedMethods" value="getFreshUserId
> setServiceSettings adaptData"/>
> </service>
> <service name="Register" provider="java:MSG">
>     <parameter name="className" value="adaptor.Register" />
>     <parameter name="allowedMethods" value="getFreshUserId
> incrementUserItemCount" />
>   </service>
> </deployment>
>
>
> *My WSDL*
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions
> targetNamespace="http://localhost:8080/SOMadapter/services/Register"
> xmlns:apachesoap="http://xml.apache.org/xml-soap"
> xmlns:impl="http://localhost:8080/SOMadapter/services/Register"
> xmlns:intf="http://localhost:8080/SOMadapter/services/Register"
> xmlns:tns1="http://adaptor"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <!--WSDL created by Apache Axis version: 1.3
> Built on Oct 05, 2005 (05:23:37 EDT)-->
> <wsdl:types>
>   <schema targetNamespace="http://adaptor"
> xmlns="http://www.w3.org/2001/XMLSchema">
>    <element name="incrementUserItemCount" type="xsd:anyType"/>
>    <element name="getFreshUserId" type="xsd:anyType"/>
>   </schema>
>   <schema
> targetNamespace="http://localhost:8080/SOMadapter/services/Register"
> xmlns="http://www.w3.org/2001/XMLSchema">
>    <element name="incrementUserItemCountReturn" type="xsd:anyType"/>
>    <element name="getFreshUserIdReturn" type="xsd:anyType"/>
>   </schema>
> </wsdl:types>
>
>    <wsdl:message name="incrementUserItemCountRequest">
>
>       <wsdl:part element="tns1:incrementUserItemCount" name="part"/>
>
>    </wsdl:message>
>
>    <wsdl:message name="incrementUserItemCountResponse">
>
>       <wsdl:part element="impl:incrementUserItemCountReturn"
> name="incrementUserItemCountReturn"/>
>
>    </wsdl:message>
>
>    <wsdl:message name="getFreshUserIdResponse">
>
>       <wsdl:part element="impl:getFreshUserIdReturn"
> name="getFreshUserIdReturn"/>
>
>    </wsdl:message>
>
>    <wsdl:message name="getFreshUserIdRequest">
>
>       <wsdl:part element="tns1:getFreshUserId" name="part"/>
>
>    </wsdl:message>
>
>    <wsdl:portType name="Register">
>
>       <wsdl:operation name="incrementUserItemCount">
>
>          <wsdl:input message="impl:incrementUserItemCountRequest"
> name="incrementUserItemCountRequest"/>
>
>          <wsdl:output message="impl:incrementUserItemCountResponse"
> name="incrementUserItemCountResponse"/>
>
>       </wsdl:operation>
>
>       <wsdl:operation name="getFreshUserId">
>
>          <wsdl:input message="impl:getFreshUserIdRequest"
> name="getFreshUserIdRequest"/>
>
>          <wsdl:output message="impl:getFreshUserIdResponse"
> name="getFreshUserIdResponse"/>
>
>       </wsdl:operation>
>
>    </wsdl:portType>
>
>    <wsdl:binding name="RegisterSoapBinding" type="impl:Register">
>
>       <wsdlsoap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>
>       <wsdl:operation name="incrementUserItemCount">
>
>          <wsdlsoap:operation soapAction=""/>
>
>          <wsdl:input name="incrementUserItemCountRequest">
>
>             <wsdlsoap:body use="literal"/>
>
>          </wsdl:input>
>
>          <wsdl:output name="incrementUserItemCountResponse">
>
>             <wsdlsoap:body use="literal"/>
>
>          </wsdl:output>
>
>       </wsdl:operation>
>
>       <wsdl:operation name="getFreshUserId">
>
>          <wsdlsoap:operation soapAction=""/>
>
>          <wsdl:input name="getFreshUserIdRequest">
>
>             <wsdlsoap:body use="literal"/>
>
>          </wsdl:input>
>
>          <wsdl:output name="getFreshUserIdResponse">
>
>             <wsdlsoap:body use="literal"/>
>
>          </wsdl:output>
>
>       </wsdl:operation>
>
>    </wsdl:binding>
>
>    <wsdl:service name="RegisterService">
>
>       <wsdl:port binding="impl:RegisterSoapBinding" name="Register">
>
>          <wsdlsoap:address
> location="http://localhost:8080/SOMadapter/services/Register"/>
>
>       </wsdl:port>
>
>    </wsdl:service>
>
> </wsdl:definitions>
>
>
> > Based on the error, my guess is that the services is not expected the
> > child element of the SOAP Body to contain the <itemcount> element. (This
> > element should be namespace qualified.)
> >
> > Can you provide the WSDL for the service?
> >
> > Anne
> >
> > On 2/22/06, *Pedro Silva* <psilva@dcc.online.pt
> > <ma...@dcc.online.pt>> wrote:
> >
> >     Hi again,
> >
> >     Sorry I sent you some buggy code, sorry. I'm looking at this for
> hours
> >
> >
> >     This is the correct code:
> >
> >     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> >     Document db = dbf.newDocumentBuilder ();
> >     Document document = db.newDocument();
> >     Element docRoot = document.createElement("itemcount");
> >     document.appendChild(docRoot);
> >     Element itemElem = document.createElement("item");
> >     itemElem.setAttribute ("userid",userId);
> >     itemElem.setAttribute("itemid",itemId);
> >     docRoot.appendChild(document.createTextNode("\n"));
> >     docRoot.appendChild(itemElem);
> >     docRoot.appendChild(document.createTextNode ("\n"));
> >
> >
> >     Service service = new Service();
> >     Call call = (Call) service.createCall();
> >     call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
> >     call.setOperationName(new QName("
> >     http://adaptor","incrementUserItemCount"));
> >
> >     SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
> >     soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
> >
> >     call.invoke(soapInput);
> >
> >
> >     and here is the error:
> >
> >
> >     AxisFault
> >     faultCode:
> >     {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
> >     faultSubcode:
> >     faultString: Couldn't find an appropriate operation for XML QName
> >     itemcount
> >     faultActor:
> >     faultNode:
> >     faultDetail:
> >             {
> http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
> >
> >     Couldn't find an appropriate operation for XML QName itemcount
> >     at
> >     org.apache.axis.message.SOAPFaultBuilder.createFault(
> SOAPFaultBuilder.java:222)
> >
> >     at ....
> >
> >     Thanks once more,
> >     Pedro Silva
> >
> >     > Hi everybody!
> >     >
> >     >
> >     > I'm trying to build some XML document and send it on the fly to a
> >     > webservice. I've managed to do this with a file using the parse
> >     method
> >     > from javax.xml.parsers, But now I'm tryning to do it building my
> >     own XML
> >     > doc.
> >     >
> >     > If I print the document I built everything looks ok, but when I
> invoke
> >     > the service I get:
> >     >
> >     > xisFault
> >     >  faultCode:
> >     > {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
> >     >  faultSubcode:
> >     >  faultString: Couldn't find an appropriate operation for XML QName
> >     > {http://adaptor}itemcount
> >     >  faultActor:
> >     >  faultNode:
> >     >  faultDetail:
> >     >       {
> http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
> >     >
> >     > Couldn't find an appropriate operation for XML QName
> >     > {http://adaptor}itemcount
> >     >       at
> >     >
> >     org.apache.axis.message.SOAPFaultBuilder.createFault(
> SOAPFaultBuilder.java:222)
> >     >       at
> >     >
> >     org.apache.axis.message.SOAPFaultBuilder.endElement(
> SOAPFaultBuilder.java:129)
> >     > ...........
> >     >
> >     >
> >     > This is the code I'm using to build the XML ands send it. I just
> can't
> >     > figure waht is wrong...
> >     >
> >     > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> >     > Document db = dbf.newDocumentBuilder();
> >     > Document document = db.newDocument();
> >     > Element docRoot=document.createElement("itemcount");
> >     > document.appendChild(docRoot);
> >     > Element itemElem = document.createElement ("item");
> >     > itemElem.setAttribute("userid",userId);
> >     > itemElem.setAttribute("itemid",itemId);
> >     > docRoot.appendChild(document.createTextNode("\n"));
> >     > docRoot.appendChild (itemElem);
> >     > docRoot.appendChild(document.createTextNode("\n"));
> >     >
> >     > Service service = new Service();
> >     > Call call = (Call) service.createCall();
> >     > call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
> >     > call.setOperationName(new QName("incrementUserItemCount"));
> >     > SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
> >     > soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
> >     > System.out.println(document.getDocumentElement());
> >     > System.out.println(soapInput[0]);
> >     > call.invoke(soapInput);
> >     >
> >     >
> >     > The simple XML doc I'm sending looks like this:
> >     > <itemcount>
> >     > <item itemid="geral" userid=""/>
> >     > </itemcount>
> >     >
> >     > Thanks in advance!
> >     > Pedro Silva
> >     >
> >     >
> >     >
> >
> >
> >
>
>
>

Re: Problem with XML QName when sending it to a webservice

Posted by Pedro Silva <ps...@dcc.online.pt>.
This a more detailed and accurate piece of my code and error.
Just so that everybody understands what I'm trying to do is for the
client to pass to my service some initializations parameters.

Pedro

*My Client Function*
private void setSOAPDefaultSetttings() throws Exception {
 Document document = db.newDocument();
 Element docRoot = document.createElement("config");
 document.appendChild(docRoot);
 Element itemElem = document.createElement("datadir");
 itemElem.setAttribute("value",dataDir);
 docRoot.appendChild(document.createTextNode("\n"));
 docRoot.appendChild(itemElem);
 docRoot.appendChild(document.createTextNode("\n"));

 Service service = new Service();
 Call call = (Call) service.createCall();

 call.setTargetEndpointAddress(new
URL("http://localhost:8080"+webServiceURL));
	call.setOperationName(new QName("setServiceSettings"));

 SOAPBodyElement[] input = new SOAPBodyElement[1];
 input[0] = new SOAPBodyElement(document.getDocumentElement());
 Vector elems = (Vector) call.invoke(input);
}

*My Service*
public Element[] setServiceSettings(Element[] sbe) {
 NodeList nl = sbe[0].getElementsByTagName("datadir");
 NamedNodeMap attrs = nl.item(0).getAttributes();
 for (int i = 0; i < attrs.getLength(); i++) {
  if ("value".equals(attrs.item(i))) {
   data.AdaptData.setDataDir(attrs.item(i).getNodeValue());
  }
 }
 Element[] elems = new Element[1];
 elems[0] = null;
 return elems;
}

*The Error*
AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode:
 faultString: Couldn't find an appropriate operation for XML QName config
 faultActor:
 faultNode:
 faultDetail:
	{http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net

Couldn't find an appropriate operation for XML QName config
	at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
[....]

*My WSDD*
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
 <service name="Adaptor" provider="java:MSG">
  <parameter name="className" value="adaptor.Adaptor"/>
  <parameter name="allowedMethods" value="getFreshUserId
setServiceSettings adaptData"/>
 </service>
 <service name="Register" provider="java:MSG">
    <parameter name="className" value="adaptor.Register" />
    <parameter name="allowedMethods" value="getFreshUserId
incrementUserItemCount" />
  </service>
</deployment>


*My WSDL*
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://localhost:8080/SOMadapter/services/Register"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost:8080/SOMadapter/services/Register"
xmlns:intf="http://localhost:8080/SOMadapter/services/Register"
xmlns:tns1="http://adaptor"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)-->
 <wsdl:types>
  <schema targetNamespace="http://adaptor"
xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="incrementUserItemCount" type="xsd:anyType"/>
   <element name="getFreshUserId" type="xsd:anyType"/>
  </schema>
  <schema
targetNamespace="http://localhost:8080/SOMadapter/services/Register"
xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="incrementUserItemCountReturn" type="xsd:anyType"/>
   <element name="getFreshUserIdReturn" type="xsd:anyType"/>
  </schema>
 </wsdl:types>

   <wsdl:message name="incrementUserItemCountRequest">

      <wsdl:part element="tns1:incrementUserItemCount" name="part"/>

   </wsdl:message>

   <wsdl:message name="incrementUserItemCountResponse">

      <wsdl:part element="impl:incrementUserItemCountReturn"
name="incrementUserItemCountReturn"/>

   </wsdl:message>

   <wsdl:message name="getFreshUserIdResponse">

      <wsdl:part element="impl:getFreshUserIdReturn"
name="getFreshUserIdReturn"/>

   </wsdl:message>

   <wsdl:message name="getFreshUserIdRequest">

      <wsdl:part element="tns1:getFreshUserId" name="part"/>

   </wsdl:message>

   <wsdl:portType name="Register">

      <wsdl:operation name="incrementUserItemCount">

         <wsdl:input message="impl:incrementUserItemCountRequest"
name="incrementUserItemCountRequest"/>

         <wsdl:output message="impl:incrementUserItemCountResponse"
name="incrementUserItemCountResponse"/>

      </wsdl:operation>

      <wsdl:operation name="getFreshUserId">

         <wsdl:input message="impl:getFreshUserIdRequest"
name="getFreshUserIdRequest"/>

         <wsdl:output message="impl:getFreshUserIdResponse"
name="getFreshUserIdResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="RegisterSoapBinding" type="impl:Register">

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

      <wsdl:operation name="incrementUserItemCount">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="incrementUserItemCountRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="incrementUserItemCountResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="getFreshUserId">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="getFreshUserIdRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="getFreshUserIdResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="RegisterService">

      <wsdl:port binding="impl:RegisterSoapBinding" name="Register">

         <wsdlsoap:address
location="http://localhost:8080/SOMadapter/services/Register"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>


> Based on the error, my guess is that the services is not expected the
> child element of the SOAP Body to contain the <itemcount> element. (This
> element should be namespace qualified.)
> 
> Can you provide the WSDL for the service?
> 
> Anne
> 
> On 2/22/06, *Pedro Silva* <psilva@dcc.online.pt
> <ma...@dcc.online.pt>> wrote:
> 
>     Hi again,
> 
>     Sorry I sent you some buggy code, sorry. I'm looking at this for hours
> 
> 
>     This is the correct code:
> 
>     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>     Document db = dbf.newDocumentBuilder ();
>     Document document = db.newDocument();
>     Element docRoot = document.createElement("itemcount");
>     document.appendChild(docRoot);
>     Element itemElem = document.createElement("item");
>     itemElem.setAttribute ("userid",userId);
>     itemElem.setAttribute("itemid",itemId);
>     docRoot.appendChild(document.createTextNode("\n"));
>     docRoot.appendChild(itemElem);
>     docRoot.appendChild(document.createTextNode ("\n"));
> 
> 
>     Service service = new Service();
>     Call call = (Call) service.createCall();
>     call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
>     call.setOperationName(new QName("
>     http://adaptor","incrementUserItemCount"));
> 
>     SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
>     soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
> 
>     call.invoke(soapInput);
> 
> 
>     and here is the error:
> 
> 
>     AxisFault
>     faultCode:
>     {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
>     faultSubcode:
>     faultString: Couldn't find an appropriate operation for XML QName
>     itemcount
>     faultActor:
>     faultNode:
>     faultDetail:
>             { http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
> 
>     Couldn't find an appropriate operation for XML QName itemcount
>     at
>     org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
> 
>     at ....
> 
>     Thanks once more,
>     Pedro Silva
> 
>     > Hi everybody!
>     >
>     >
>     > I'm trying to build some XML document and send it on the fly to a
>     > webservice. I've managed to do this with a file using the parse
>     method
>     > from javax.xml.parsers, But now I'm tryning to do it building my
>     own XML
>     > doc.
>     >
>     > If I print the document I built everything looks ok, but when I invoke
>     > the service I get:
>     >
>     > xisFault
>     >  faultCode:
>     > {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
>     >  faultSubcode:
>     >  faultString: Couldn't find an appropriate operation for XML QName
>     > {http://adaptor}itemcount
>     >  faultActor:
>     >  faultNode:
>     >  faultDetail:
>     >       { http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
>     >
>     > Couldn't find an appropriate operation for XML QName
>     > {http://adaptor}itemcount
>     >       at
>     >
>     org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
>     >       at
>     >
>     org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
>     > ...........
>     >
>     >
>     > This is the code I'm using to build the XML ands send it. I just can't
>     > figure waht is wrong...
>     >
>     > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>     > Document db = dbf.newDocumentBuilder();
>     > Document document = db.newDocument();
>     > Element docRoot=document.createElement("itemcount");
>     > document.appendChild(docRoot);
>     > Element itemElem = document.createElement ("item");
>     > itemElem.setAttribute("userid",userId);
>     > itemElem.setAttribute("itemid",itemId);
>     > docRoot.appendChild(document.createTextNode("\n"));
>     > docRoot.appendChild (itemElem);
>     > docRoot.appendChild(document.createTextNode("\n"));
>     >
>     > Service service = new Service();
>     > Call call = (Call) service.createCall();
>     > call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
>     > call.setOperationName(new QName("incrementUserItemCount"));
>     > SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
>     > soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
>     > System.out.println(document.getDocumentElement());
>     > System.out.println(soapInput[0]);
>     > call.invoke(soapInput);
>     >
>     >
>     > The simple XML doc I'm sending looks like this:
>     > <itemcount>
>     > <item itemid="geral" userid=""/>
>     > </itemcount>
>     >
>     > Thanks in advance!
>     > Pedro Silva
>     >
>     >
>     >
> 
> 
> 



Re: Problem with XML QName when sending it to a webservice

Posted by Anne Thomas Manes <at...@gmail.com>.
Based on the error, my guess is that the services is not expected the child
element of the SOAP Body to contain the <itemcount> element. (This element
should be namespace qualified.)

Can you provide the WSDL for the service?

Anne

On 2/22/06, Pedro Silva <ps...@dcc.online.pt> wrote:
>
> Hi again,
>
> Sorry I sent you some buggy code, sorry. I'm looking at this for hours
>
>
> This is the correct code:
>
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> Document db = dbf.newDocumentBuilder();
> Document document = db.newDocument();
> Element docRoot = document.createElement("itemcount");
> document.appendChild(docRoot);
> Element itemElem = document.createElement("item");
> itemElem.setAttribute("userid",userId);
> itemElem.setAttribute("itemid",itemId);
> docRoot.appendChild(document.createTextNode("\n"));
> docRoot.appendChild(itemElem);
> docRoot.appendChild(document.createTextNode("\n"));
>
>
> Service service = new Service();
> Call call = (Call) service.createCall();
> call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
> call.setOperationName(new QName("http://adaptor
> ","incrementUserItemCount"));
>
> SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
> soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
>
> call.invoke(soapInput);
>
>
> and here is the error:
>
>
> AxisFault
> faultCode:
> {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
> faultSubcode:
> faultString: Couldn't find an appropriate operation for XML QName
> itemcount
> faultActor:
> faultNode:
> faultDetail:
>         {http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
>
> Couldn't find an appropriate operation for XML QName itemcount
> at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java
> :222)
> at ....
>
> Thanks once more,
> Pedro Silva
>
> > Hi everybody!
> >
> >
> > I'm trying to build some XML document and send it on the fly to a
> > webservice. I've managed to do this with a file using the parse method
> > from javax.xml.parsers, But now I'm tryning to do it building my own XML
> > doc.
> >
> > If I print the document I built everything looks ok, but when I invoke
> > the service I get:
> >
> > xisFault
> >  faultCode:
> > {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
> >  faultSubcode:
> >  faultString: Couldn't find an appropriate operation for XML QName
> > {http://adaptor}itemcount
> >  faultActor:
> >  faultNode:
> >  faultDetail:
> >       {http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
> >
> > Couldn't find an appropriate operation for XML QName
> > {http://adaptor}itemcount
> >       at
> > org.apache.axis.message.SOAPFaultBuilder.createFault(
> SOAPFaultBuilder.java:222)
> >       at
> > org.apache.axis.message.SOAPFaultBuilder.endElement(
> SOAPFaultBuilder.java:129)
> > ...........
> >
> >
> > This is the code I'm using to build the XML ands send it. I just can't
> > figure waht is wrong...
> >
> > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> > Document db = dbf.newDocumentBuilder();
> > Document document = db.newDocument();
> > Element docRoot=document.createElement("itemcount");
> > document.appendChild(docRoot);
> > Element itemElem = document.createElement("item");
> > itemElem.setAttribute("userid",userId);
> > itemElem.setAttribute("itemid",itemId);
> > docRoot.appendChild(document.createTextNode("\n"));
> > docRoot.appendChild(itemElem);
> > docRoot.appendChild(document.createTextNode("\n"));
> >
> > Service service = new Service();
> > Call call = (Call) service.createCall();
> > call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
> > call.setOperationName(new QName("incrementUserItemCount"));
> > SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
> > soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
> > System.out.println(document.getDocumentElement());
> > System.out.println(soapInput[0]);
> > call.invoke(soapInput);
> >
> >
> > The simple XML doc I'm sending looks like this:
> > <itemcount>
> > <item itemid="geral" userid=""/>
> > </itemcount>
> >
> > Thanks in advance!
> > Pedro Silva
> >
> >
> >
>
>
>

Re: Problem with XML QName when sending it to a webservice

Posted by Pedro Silva <ps...@dcc.online.pt>.
Hi again,

Sorry I sent you some buggy code, sorry. I'm looking at this for hours


This is the correct code:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document db = dbf.newDocumentBuilder();
Document document = db.newDocument();
Element docRoot = document.createElement("itemcount");
document.appendChild(docRoot);
Element itemElem = document.createElement("item");
itemElem.setAttribute("userid",userId);
itemElem.setAttribute("itemid",itemId);
docRoot.appendChild(document.createTextNode("\n"));
docRoot.appendChild(itemElem);
docRoot.appendChild(document.createTextNode("\n"));


Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
call.setOperationName(new QName("http://adaptor","incrementUserItemCount"));

SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
soapInput[0] = new SOAPBodyElement(document.getDocumentElement());

call.invoke(soapInput);


and here is the error:


AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode:
 faultString: Couldn't find an appropriate operation for XML QName itemcount
 faultActor:
 faultNode:
 faultDetail:
	{http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net

Couldn't find an appropriate operation for XML QName itemcount
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at ....

Thanks once more,
Pedro Silva

> Hi everybody!
> 
> 
> I'm trying to build some XML document and send it on the fly to a
> webservice. I've managed to do this with a file using the parse method
> from javax.xml.parsers, But now I'm tryning to do it building my own XML
> doc.
> 
> If I print the document I built everything looks ok, but when I invoke
> the service I get:
> 
> xisFault
>  faultCode:
> {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
>  faultSubcode:
>  faultString: Couldn't find an appropriate operation for XML QName
> {http://adaptor}itemcount
>  faultActor:
>  faultNode:
>  faultDetail:
> 	{http://xml.apache.org/axis/}hostname:kheijo.dracus.homeip.net
> 
> Couldn't find an appropriate operation for XML QName
> {http://adaptor}itemcount
> 	at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
> 	at
> org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
> ...........
> 
> 
> This is the code I'm using to build the XML ands send it. I just can't
> figure waht is wrong...
> 
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> Document db = dbf.newDocumentBuilder();
> Document document = db.newDocument();
> Element docRoot=document.createElement("itemcount");
> document.appendChild(docRoot);
> Element itemElem = document.createElement("item");
> itemElem.setAttribute("userid",userId);
> itemElem.setAttribute("itemid",itemId);
> docRoot.appendChild(document.createTextNode("\n"));
> docRoot.appendChild(itemElem);
> docRoot.appendChild(document.createTextNode("\n"));
> 
> Service service = new Service();
> Call call = (Call) service.createCall();
> call.setTargetEndpointAddress(new URL(localUrl+webServiceURL));
> call.setOperationName(new QName("incrementUserItemCount"));
> SOAPBodyElement[] soapInput = new SOAPBodyElement[1];
> soapInput[0] = new SOAPBodyElement(document.getDocumentElement());
> System.out.println(document.getDocumentElement());
> System.out.println(soapInput[0]);
> call.invoke(soapInput);
> 
> 
> The simple XML doc I'm sending looks like this:
> <itemcount>
> <item itemid="geral" userid=""/>
> </itemcount>
> 
> Thanks in advance!
> Pedro Silva
> 
> 
>