public static String getXmlElementValue(String xml, String element) {
//Search for the element with name spaceintstartInd=xml.indexOf(":"+element+">");if(startInd==-1){//Element with name space not foundstartInd=xml.indexOf("<"+element+">");//Element not foundif(startInd==-1){returnnull;}}//Search for the end for the element. This is because of the name spacestartInd=xml.indexOf('>',startInd);if(startInd==-1){//Element end not foundreturnnull;}//Find the closing elementintendInd=xml.indexOf("</",startInd);if(endInd==-1||endInd<=startInd){//This could be an empty elementreturnnull;}//Element found. Return its valuereturnxml.substring(startInd+1,endInd);}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks a lot. I've updated the code with your inputs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2013-05-10
I am getting below exception when i try to test the sevice. I am using 1.0.0. version.
java.lang.NullPointerException
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createVersionedMessage(MessageFactoryImpl.java:193)
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createVersionedMessage(MessageFactoryImpl.java:182)
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:145)
at net.sf.sripathi.ws.mock.util.SoapUtil.getOperationName(SoapUtil.java:73)
at net.sf.sripathi.ws.mock.Service.getMockResponse(Service.java:158)
at net.sf.sripathi.ws.mock.servlet.MockServlet.service(MockServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:176)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for sharing the information. Looks like the SAAJ implementation you are using is causing the problem. Its working well with SAAJ API provided as part of JRE1.6 and saaj-impl (1.3.2) provided by SUN.
Regards,
Sripathi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Sripathi - I did try to contact you a few days back but I have taken your code base and have enhanced it so that it can save the mocked responses on file system so on restart it maintains that state. Also, I have springified the project and did a few clean ups (logging, structural change) - was hoping to get your inputs on how I can contribute and maybe upload this back on github?
Let me know - my email id is arun0009@yahoo.com
Thanks,
Arun
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Apologies for late response, been held up with my regular work.
Regarding the saving the files in local directory, the easiest way is to
add the environment var in web.xml and slight change to the Servlet to take
the work space as defined in the web.xml.
I did not want to use spring framework as it adds to the overall size of
the bundle. I'm even working on removing the soapUI lib dependency to
reduce the overall size.
Hi Sripathi - I did try to contact you a few days back but I have taken
your code base and have enhanced it so that it can save the mocked
responses on file system so on restart it maintains that state. Also, I
have springified the project and did a few clean ups (logging, structural
change) - was hoping to get your inputs on how I can contribute and maybe
upload this back on github?
Following tests failed:
public class SoapUtilTest {
}
It can be repaired with:
public static String getXmlElementValue(String xml, String element) {
Thanks a lot. I've updated the code with your inputs.
I am getting below exception when i try to test the sevice. I am using 1.0.0. version.
java.lang.NullPointerException
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createVersionedMessage(MessageFactoryImpl.java:193)
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createVersionedMessage(MessageFactoryImpl.java:182)
at oracle.j2ee.ws.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:145)
at net.sf.sripathi.ws.mock.util.SoapUtil.getOperationName(SoapUtil.java:73)
at net.sf.sripathi.ws.mock.Service.getMockResponse(Service.java:158)
at net.sf.sripathi.ws.mock.servlet.MockServlet.service(MockServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:176)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Hi,
Thanks for your inputs. Would it be possible to share the WSDL and SOAP request?
Regards,
Sripathi
My Input:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mcs="http://services.mcs.smp.tenergy.tsystems.com/MCS/">
<soapenv:header>
<soapenv:body>
<mcs:getstatus>
<mushostname>002569624318</mushostname>
<meterparameters>
<action>Retrieve</action>
<ssl>false</ssl>
</meterparameters>
<username>U709</username><passphrase>AAMCCwQHdQd+fwR3</passphrase>
</mcs:getstatus>
</soapenv:body>
</soapenv:header></soapenv:envelope>
My Wsdl:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://services.mcs.smp.tenergy.tsystems.com/MCS/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="mcs" targetnamespace="http://services.mcs.smp.tenergy.tsystems.com/MCS/">
<types>
<xsd:schema>
<xsd:import namespace="http://services.mcs.smp.tenergy.tsystems.com/MCS/" schemalocation="mcs_objects.xsd">
</xsd:import></xsd:schema>
</types></definitions>
Hi,
Thanks for sharing the information. Looks like the SAAJ implementation you are using is causing the problem. Its working well with SAAJ API provided as part of JRE1.6 and saaj-impl (1.3.2) provided by SUN.
Regards,
Sripathi
Hi Sripathi - I did try to contact you a few days back but I have taken your code base and have enhanced it so that it can save the mocked responses on file system so on restart it maintains that state. Also, I have springified the project and did a few clean ups (logging, structural change) - was hoping to get your inputs on how I can contribute and maybe upload this back on github?
Let me know - my email id is arun0009@yahoo.com
Thanks,
Arun
Hi Arun,
Apologies for late response, been held up with my regular work.
Regarding the saving the files in local directory, the easiest way is to
add the environment var in web.xml and slight change to the Servlet to take
the work space as defined in the web.xml.
I did not want to use spring framework as it adds to the overall size of
the bundle. I'm even working on removing the soapUI lib dependency to
reduce the overall size.
Regards,
Sripathi
On 11 July 2013 18:58, Arun Gopalpuri arun0009@users.sf.net wrote: