Testing web services in Netbeans - java

1.I created web services in netbeans using jboss 7, n i testing by typing the url into the browser and it came up like this..
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>
No such operation: null (HTTP GET PATH_INFO: /UnitConversion11/UnitConversion11null)
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
So does anybody knows what the problem is because I have no idea.Is there anything about the xml file? and where is the xml fil :(

I think this is because your SOAP request wasn't correctly formulated. You normally use this SOAP by posting ugly blobs of XML everywhere. Your simple GET request probably isn't handled by the application you wrote.
From my hazy memory, there is a field in the request called something like soap:operation that identifies which bit of code will end up processing the request and this is of course missing from the GET request.
You could try testing your app using something like SOAPUI, curl, httprequester (..etc) to send a properly formulated SOAP request via POST or you could adapt your code to properly handle the GET request (possibly identified by having a null soap:operation?)
HTH

Related

is it possible to process the SOAP xml request using java code and get the response?

I have SOAP request XML but i don't have URL.
so is it possible to process the request using java code and get the response?
i have searched on this but i got only by url we can do. I am new to SOAP.

SoapUI doesn't print multi-byte characters correctly

I have a java web service that I want to invoke using soapUI.
I want that SOAPUI shows the character ’ correctly for example in a SOAP response I get the below response :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Internal server Error </faultstring>
<detail>
<MYENDPOINT_NAME xmlns="MY_XMLNS">
<ns2:code>INTROUVABLE</ns2:code>
<ns2:message>Le fichier n□a pas été trouvé</ns2:message>
</MYENDPOINT_NAME>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I want it to be like :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>500 Internal server Error </faultstring>
<detail>
<MY_ENDPOINT_NAME xmlns="MY_XMLNS">
<ns2:code>INTROUVABLE</ns2:code>
<ns2:message>Le fichier n’a pas été trouvé</ns2:message>
</MY_ENDPOINT_NAME>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I tried to specify the charset in SOAP requests using UTF-8 and in the launching script using
-Dfile.encoding=UTF-8, but it still outputs the same result.
NB. the 500 Internal server Error is a normal functional behaviour in this case.
Couple of things.
Change the file.encoding value to UTF-8 in the SOAPUI_HOME/bin/soapui.bat. Make sure you have a backup of the file before making any changes.
In the SoapUI, Menu -> File -> Preferences -> UI Settings, Click the check box for Native L&F. Save the preferences. You many find more preferences here in the documentation.
Now close the SoapUI tool.
Open the command prompt; Go to %SOAPUI_HOME%\bin directory. Run soapui.bat
Suggestion: If you donot want to do that all the times, put SOAPUI_HOME/bin in PATH environment variable. Next time, soapui.bat should work from command prompt (irrespective of where you are present)
EDIT:
Another angle is to look at the application / server perspective. See if the application is configured to use file.encoding as UTF-8. If not, try configuring the application and retry.

Error while sending attachment to Soap web service

On running the example provided in the link https://hc.apache.org/httpcomponents-client-ga/httpmime/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java, I am getting the below exception
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: multipart/form-data; boundary=APQdLVD1_Zc9bPMSMCmGCk012pvQ6Yv Supported ones are: [text/xml]
Any idea why it is coming?
I think you are confusing two topics:
A HTML form post
A SOAP request post
In the former you indeed send a multipart/form-data as you seem to have done.
In the latter you generally don't send multiparts (unless you are using something like MTOM) but simply post the entire content as "application/soap+xml"
When using MTOM, you don't use multipart/form-data but multipart/related and you still need to follow some conventions that are not found in HTML and as such not in the example code you posted.

Parse a SOAP request and modify data

I am developing an application to send a text message/sms to a user base and receive their responses. I have been given a wsdl which I have used to consume the service to sendsms using netbeans IDE .So far so good.
Now the problem is when I receive a text message a soap request is posted over to a location on our server. The request-response is as follows:
<a>http://www.csoft.co.uk/sms/api/sms_to_soap.htm</a>
I have checked the provider's sample API section but they do not have any material that does something similar.
My question is how do I parse the soap request and send the corresponding response? Also I have to check the messages and filter them for offensive/obscene content. I have the wsdl, xsd, java classes generated by netbeans, but I cant get around how to use them to achieve the goal. Any help or a pointer in the right direction would be greatly appreciated.
Thanks
Kalyan
Please search Stackoverflow and Google, there is plenty of howto around.
Even in this question, just check on the right at "related".

Microsoft SSRS consuming JAX-WS Web Service

I have developed a Web Service using JAX-WS (v2.1.3 - Sun JDK 1.6.0_05) that works just fine when I use a Java client or SoapUI or other Web Services testing tools. I need to consume this service using 2005 Microsoft SQL Server Reporting Services and I get the following error
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>Couldn't create SOAP message due to exception: XML reader error: unexpected character content:
"?"
</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
If I use a HTTP proxy to sniff out what SSRS is sending, I see EF BB BF as the beginning of the post body and JAX-WS doesn't like that. If I remove the special characters and resubmit the request using Fiddler, then the web-service invocation works.
My question is why does SSRS introduce these special characters and how can I make it stop? If I can't stop it, how can I get JAX-WS to ignore them? Here is my SSRS query:
<Query>
<Method Name="getOneUser" Namespace="http://vinny.com" >
</Method>
</Query>
I've also tried a query like this below:
<Query>
<Method Name="getOneUser" Namespace="http://vinny.com" >
</Method>
<SoapAction>http://vinny.com/getOneUser</SoapAction>
<ElementPath IgnoreNamespaces="true">*</ElementPath>
</Query>
Does anyone have any ideas on what I can try? I've tried several different types of annotations on the JAX-WS side to change the type of SOAPBinding, etc. but nothing seem to make it work with Microsoft SSRS.
The "Special characters" are the "Byte order marker" (BOM) indicating that the post body is UTF-8. http://unicode.org/faq/utf_bom.html#BOM
The Java service should be smart enough not to puke on these characters; I'm afraid I don't know how to help it.

Categories