[JBossWS] - Simple Problem ? - SOAPBody.addDocument()
by Jonathan.Martin
Hi,
I wanted to write a "Raw" style web service as described in the JBoss documentation. But am having problems in adding a org.w3c.dom.Document to the SOAPBody using the SOAPBody.addDocument(Document) method.
My client is trying to create a SOAPMessage as follows:
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage reqMsg = mf.createMessage();
String request =
"<ns1:Order xmlns:ns1='" + "http://testnamespace" +
"' xmlns:ns2='http://somens' attrval='somevalue'>" +
" <ns2:Customer>Kermit</ns2:Customer>" +
" Ferrari" +
"</ns1:Order>";
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(request.getBytes()));
reqMsg.getSOAPBody().addDocument(doc);
reqMsg.writeTo(System.out);
But the request message is never created because of the following error when adding the document to the SOAPBody:
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces
If anyone could point me in the correct direction it would be hugely appreciated.
Cheers,
Jon.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986091#3986091
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986091
18 years, 1 month
[JBossWS] - Re: Problem with SAAJ Client for Webservice that receives at
by RomeuFigueira
Finally managed to fix this.
After spending the last hours dealing with JBossWS source-code, I've managed to do a small change that enabled my message to be correctly interpreted.
If you remmember I wasn't specifining in my mimeheaders, where my rootpart was. The problem was that the class MultipartRelatedDecoder wasn't computing a valid MIME boundary, the one I was getting was messy, making the code skip my text/xml part into the attachment part, thus giving out those errors.
After interpreting both InputStreams, the main difference from any of my standalone clients and the SOAPUi or the Junit test reports was that without a start part, my InputStream started in the first line, while the other started a line below.
So, in order to enable a detection of a valid boundary, I had to do the following change to MultipartRelatedDecoder.java:
old:
| try
| {
| boundary = ("\r\n--" + boundaryParameter).getBytes("US-ASCII");
| }
|
new:
| try
| {
| if(start==null)
| boundary = ("--" + boundaryParameter).getBytes("US-ASCII");
| else
| boundary = ("\r\n--" + boundaryParameter).getBytes("US-ASCII");
| }
|
This way, both systems work. IMO the old code is a little bit too hard-coded in this aspect, giving a weird error when the simple difference between files was a linefeed (which I didn't program in my code, it was introduced through the communication layer).
Perhaps this aspect could be improved.
Thanks for making this project opensource, if not it would have been almost impossible to work this out.
Regards,
Romeu
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3985919#3985919
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3985919
18 years, 1 month
[JBossWS] - Re: Exception while deploying a webservice with attachment (
by mnsharif
Yeah, the generated jaxrpc-mapping.xml does have <param-type>java.lang.String</param-type> and Yes, i do have .... type='xsd:string'/> like thing in my part definitions in WSDL. But that is there for a reason, which i will try to explain.
As a matter of fact, wscompile does not allow to have primitive types (like xsd:string etc) to be specified like following:
<message name = "methodName">
| <part name = "paraName" element = "xsd:string"/>
| </message>
If used, wscompile gives error and skips mapping for this method. Please note that this behavior is peculiar to document based web wervices _only_ (this is allowed in rpc style). So, in document based services, i have to wrap these primitive types in wrapper types like this
<message name = "methodName">
| <part name = "paraName" element = "ns2:wrapperString"/>
| </message>
and then, combination of following fragment in types section of the WSDL gives me the equavilent desired effect.
<complexType name = "wrapperStringType">
| <sequence>
| <element
| name = "parameterOne"
| type = "string"
| nillable = "true"/>
| </sequence>
| </complexType>
| <element name = "wrapperString" type = "tns:wrapperStringType"/>
|
Now everything is fine with attachment-less webservices. But for the web-service where i need attachment support, the message _has_ to be defined as
<message name = "methodWithAttachment">
| <part name = "paraName" element = "ns2:wrapperString"/>
| <part name = "attachmentContents" type = "xsd:string"/>
| </message>
Interestingly enough, the wscompile tool does _not_ show any error/warning while generating mapping. The attachmentContents above is my parameter defined in mime:content (which happens to be of type text/plain), so that could be the possible reason of wscompile staying silent on this part being specified as xsd:string.
But at deployment time i get the following warning and then exception (as i mentioned in my first post):
anonymous wrote : 22:11:09,354 WARN [JavaWsdlMapping] Cannot find jaxrpc-mapping for type: {http://www.w3.org/2001/XMLSchema}string
| 22:11:09,354 ERROR [MainDeployer] Could not create deployment: file:/D:/jboss-4.0.4.GA/server/default/deploy/alhamd.war
| org.jboss.ws.WSException: Cannot obtain java/xml type mapping for: {http://www.w3.org/2001/XMLSchema}string
| at org.jboss.ws.deployment.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilder.java:513)
|
Phew! No wonder, writing this all down is more difficult than explaining on face.
mnsharif
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3985912#3985912
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3985912
18 years, 1 month