axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pedro Silva <psi...@dcc.online.pt>
Subject Re: Problem with XML QName when sending it to a webservice
Date Thu, 23 Feb 2006 00:38:31 GMT
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
> 
> 
> 



Mime
View raw message