如何在eclipse的 Axis插件自动生成的webService相关文件中加入SOAP-HTTP信息
问题:在一个项目中遇到soap协议中要加入报文头验证的问题。
由于采用eclipse下axis 插件自动生成的webService相关文件。所有要在报文协议中加入报文头,需要修改自动生成的代码,第三方给出的要求增加报文头的文档
第三方STB自服务系统登陆时需要事前提供给第三方STB自服务系统的登陆名、密码,这些信息保存在SOAP-http请求的头信息中,头域定义如下表
HTTP头域
含义
STB_SelfService_USERNAME
第三方STB自服务系统登陆名,本版本为StarSTB SelfService
STB_SelfService_PASSWORD
第三方STB自服务系统登陆密码,本版本为StarSTB SelfService
SOAP命名空间名称为:NAMESPACE_STARSMS。
/** * IStbSelfServiceLocator.java * * This file was auto-generated from WSDL * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter. */package com.star.sms.stb.service;import org.apache.axis.message.SOAPHeaderElement;public class IStbSelfServiceLocator extends org.apache.axis.client.Service implements com.star.sms.stb.service.IStbSelfService { public IStbSelfServiceLocator() { } public IStbSelfServiceLocator(org.apache.axis.EngineConfiguration config) { super(config); } public IStbSelfServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { super(wsdlLoc, sName); } // Use to get a proxy class for IStbSelfServiceHttpPort private java.lang.String IStbSelfServiceHttpPort_address = "http://localhost:8080/stbselfserviceproxy/stbSelfService"; public java.lang.String getIStbSelfServiceHttpPortAddress() { return IStbSelfServiceHttpPort_address; } // The WSDD service name defaults to the port name. private java.lang.String IStbSelfServiceHttpPortWSDDServiceName = "IStbSelfServiceHttpPort"; public java.lang.String getIStbSelfServiceHttpPortWSDDServiceName() { return IStbSelfServiceHttpPortWSDDServiceName; } public void setIStbSelfServiceHttpPortWSDDServiceName(java.lang.String name) { IStbSelfServiceHttpPortWSDDServiceName = name; } public com.star.sms.stb.service.IStbSelfServicePortType getIStbSelfServiceHttpPort() throws javax.xml.rpc.ServiceException { java.net.URL endpoint; try { endpoint = new java.net.URL(IStbSelfServiceHttpPort_address); } catch (java.net.MalformedURLException e) { throw new javax.xml.rpc.ServiceException(e); } return getIStbSelfServiceHttpPort(endpoint); } public com.star.sms.stb.service.IStbSelfServicePortType getIStbSelfServiceHttpPort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { try { com.star.sms.stb.service.IStbSelfServiceHttpBindingStub _stub = new com.star.sms.stb.service.IStbSelfServiceHttpBindingStub(portAddress, this); _stub.setPortName(getIStbSelfServiceHttpPortWSDDServiceName()); _stub.setHeader(new SOAPHeaderElement("NAMESPACE_STARSMS","STB_SelfService_USERNAME","StarSTBSelfService")); _stub.setHeader(new SOAPHeaderElement("NAMESPACE_STARSMS","STB_SelfService_PASSWORD","StarSTBSelfService")); return _stub; } catch (org.apache.axis.AxisFault e) { return null; } } public void setIStbSelfServiceHttpPortEndpointAddress(java.lang.String address) { IStbSelfServiceHttpPort_address = address; } /** * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { try { if (com.star.sms.stb.service.IStbSelfServicePortType.class.isAssignableFrom(serviceEndpointInterface)) { com.star.sms.stb.service.IStbSelfServiceHttpBindingStub _stub = new com.star.sms.stb.service.IStbSelfServiceHttpBindingStub(new java.net.URL(IStbSelfServiceHttpPort_address), this); _stub.setPortName(getIStbSelfServiceHttpPortWSDDServiceName()); return _stub; } } catch (java.lang.Throwable t) { throw new javax.xml.rpc.ServiceException(t); } throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); } /** * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { if (portName == null) { return getPort(serviceEndpointInterface); } java.lang.String inputPortName = portName.getLocalPart(); if ("IStbSelfServiceHttpPort".equals(inputPortName)) { return getIStbSelfServiceHttpPort(); } else { java.rmi.Remote _stub = getPort(serviceEndpointInterface); ((org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; } } public javax.xml.namespace.QName getServiceName() { return new javax.xml.namespace.QName("http://service.stb.sms.star.com", "IStbSelfService"); } private java.util.HashSet ports = null; public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); ports.add(new javax.xml.namespace.QName("http://service.stb.sms.star.com", "IStbSelfServiceHttpPort")); } return ports.iterator(); } /** * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException {if ("IStbSelfServiceHttpPort".equals(portName)) { setIStbSelfServiceHttpPortEndpointAddress(address); } else{ // Unknown Port Name throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); } } /** * Set the endpoint address for the specified port name. */ public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { setEndpointAddress(portName.getLocalPart(), address); }}