使用 WSDL 部署 Web 服务: 第 1 部分 Web 服务和 WSDL 简介

摘自http://www-128.ibm.com/developerworks/cn/webservices/ws-intwsdl/part1/index.html使用WSDL部署Web服务:第1部分Web服务和WSDL简介级别:初级BilalSiddiqui,CEO,WAPMonster2001年11月01日在“使用WSDL
展开阅读全文

Web Services wsdl相关

07-18

由wsdl生成java代码,再写测试代码对已部署在tomcat上的服务进行junit测试,报如下错误rnorg.apache.axis2.AxisFault: WSHandler: Signature: error during message procesingorg.apache.ws.security.WSSecurityException: General security error (WSEncryptBody/WSSignEnvelope: Element to encrypt/sign not found: http://schemas.xmlsoap.org/soap/envelope/, Body)rn at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)rn at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)rn at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)rn at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)rn at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)rn at com.huawei.bme.winuvsinterface.UVSInterface_ExtendStub.BalanceAdjust(UVSInterface_ExtendStub.java:448)rn at com.huawei.bme.winuvsinterface.UVSInterface_ExtendStubTest.testBalanceAdjust(UVSInterface_ExtendStubTest.java:47)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)rn at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)rn at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)rn at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)rn at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)rn at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)rn at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)rn at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:220)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 论坛

根据已有wsdl文件用axis建立web service服务

08-04

首先wsdl文件是:rnrnrn rnrn rn rn rn rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn其次根据这个文件用代码生成一个可调用的web service,注意这个wsdl的style是message:rnWSDDDeployment deployment = getWSDDDeployment();rnrn Collection portTypes = wsdl.getPortTypes().values();rn for (Iterator portIter = portTypes.iterator(); portIter.hasNext();) rn // SOAPService service = new SOAPService(new MsgProvider());rn WSDDService service = new WSDDService();rn ServiceDesc desc = service.getServiceDesc();rn service.setQName(new QName(name));rn service.setName(name);rn service.setProviderQName(new QName(WSDDConstants.URI_WSDD_JAVA,rn "MsbusProvider"));rn desc.setName(name);rn desc.setStyle(Style.MESSAGE);rn desc.setUse(Use.LITERAL);rn Map nsMap = wsdl.getNamespaces();rn desc.setNamespaceMappings(new ArrayList(nsMap.entrySet()));rnrn PortType portType = (PortType) portIter.next();rn List operations = portType.getOperations();rn for (Iterator oIter = operations.iterator(); oIter.hasNext();) rn Operation operation = (Operation) oIter.next();rn Collection inParts = null;rn OperationDesc operationDesc = new OperationDesc();rn operationDesc.setName(operation.getName());rn Input in = operation.getInput();rn inParts = in.getMessage().getParts().values();rn for (Iterator partIter = inParts.iterator(); partIter.hasNext();) rn Part part = (Part) partIter.next();rn ParameterDesc paramDesc = new ParameterDesc();rn paramDesc.setName(part.getName());rn paramDesc.setQName(new QName(ns, part.getName()));rn paramDesc.setTypeQName(new QName(ns, "Element[]"));rn paramDesc.setMode(ParameterDesc.IN);rnrn operationDesc.addParameter(paramDesc);rn rn Output out = operation.getOutput();rn Collection outParts = null;rn if (out != null)rn outParts = out.getMessage().getParts().values();rn if (outParts != null) rn Part part = (Part) outParts.iterator().next();rn operationDesc.setReturnQName(new QName(ns, part.getName()));rn operationDesc.setReturnType(new QName(ns, "Element[]"));rn service.addOperation(new WSDDOperation(operationDesc));rn rn rn service.setOptionsHashtable(new Hashtable());rn try rn // validate descriptor before deploying servicern service.validateDescriptors();rn catch (WSDDException e) rn throw new DeploymentException("Invalid WSDD", e);rn rn // config.deployService(name, service);rn deployment.deployService(service);rn rnrn运行一个测试程序访问该服务器,报错:rnrnjava.lang.ClassCastException: java.util.HashMap$Entryrn at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)rn at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)rn at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)rn at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1306)rn at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)rn at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)rn at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:207)rn at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:292)rn at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)rn at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)rn at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)rn at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)rn at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)rn at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)rn at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)rn at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)rn at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)rn at org.apache.axis.client.Call.invokeEngine(Call.java:2784)rn at org.apache.axis.client.Call.invoke(Call.java:2767)rn at org.apache.axis.client.Call.invoke(Call.java:1792)rn at com.sobey.msbus.engine.test.MsgServiceTester.main(MsgServiceTester.java:41)rnrn实在不知道我代码那里有错,希望高手指点一二,万分感谢. 论坛

没有更多推荐了,返回首页