import java.rmi.RemoteException; import javax.xml.rpc.ParameterMode; import javax.xml.rpc.ServiceException; import javax.xml.soap.SOAPException; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import org.apache.axis.message.SOAPHeaderElement; public class SOAPHepler { public static void main(String[] args) throws ServiceException, RemoteException { try { String endpointURL = "http://122.228.134.30:2121/EtoneWebService.asmx?WSDL"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpointURL)); call.setSOAPActionURI("http://tempuri.org/" + "getPhoneArea"); call.setOperationName("getPhoneArea"); SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement("http://tempuri.org/", "etoneSoapHeader"); soapHeaderElement.setNamespaceURI("http://tempuri.org/"); try { soapHeaderElement.addChildElement("UserName").setValue("admin"); soapHeaderElement.addChildElement("Password").setValue("123"); } catch (SOAPException e) { e.printStackTrace(); } call.addHeader(soapHeaderElement); call.setReturnType(XMLType.XSD_STRING); call.addParameter("mobile", XMLType.XSD_STRING, ParameterMode.IN); String ret = (String) call.invoke(new Object[] { "18268136200" }); System.out.println(ret); } catch (Exception e) { e.printStackTrace(); } } }我实质上是想打印请求报文的内容的,或者用什么工具捕获请求的报文
用SOAPUI 工具试试..这个工具主要调试webservice的
<module ref="logging"/>完整的例子如下:
<service name="myService"> <description> 使用logging模块 </description> <!-- 引用logging模块 --> <module ref="logging"/> <parameter name="ServiceClass"> service.MyService </parameter> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </messageReceivers>
具体过程参考: http://blog.csdn.net/thinkpadshi/article/details/8199027
######axis框架本身用了Log4j吧,直接打印啊。把log4j.properties文件里级别改成debug######你好,我用了Axis框架里的Log4j, # Set root category priority to INFO and its only appender to CONSOLE. #log4j.rootCategory=INFO, CONSOLE log4j.rootCategory=DEBUG, CONSOLE 设置完后,没有打印出来呀?######
你好,我用了Axis框架里的Log4j,
# Set root category priority to INFO and its only appender to CONSOLE. #log4j.rootCategory=INFO, CONSOLE
log4j.rootCategory=DEBUG, CONSOLE
设置完后,没有打印出来啊? ###### 或者说我要发这样一个报文来请求WebService,程序中哪里错了,为什么一直请求不成功?
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:Header>
<tem:etoneSoapHeader>
<!--Optional:-->
<tem:UserName>admin</tem:UserName>
<!--Optional:-->
<tem:Password>123</tem:Password>
<!--Optional:-->
<tem:StateLt>?</tem:StateLt>
<!--Optional:-->
<tem:StateYd>?</tem:StateYd>
<!--Optional:-->
<tem:StateDx>?</tem:StateDx>
<!--Optional:-->
<tem:Ydinterface>?</tem:Ydinterface>
</tem:etoneSoapHeader>
</soap:Header>
<soap:Body>
<tem:getPhoneArea>
<!--Optional:-->
<tem:mobile>18268136200</tem:mobile>
</tem: getPhoneArea >
</soap:Body>
</soap:Envelope>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。