the soupui requeset工作正常,但是当我尝试java代码没有工作时,我真的对这个问题感到困惑。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:port="http://service.composit.unic.capsa.com/UNICService/port" xmlns:sch="http://www.ibm.com/mdm/schema">
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>mdmadmin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mdmadmin</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header>
<soapenv:Body>
<port:checkHeartBeatInfo>
<sch:RequestControl>
<sch:requestID>112</sch:requestID>
<sch:DWLControl>
<sch:requesterName>111</sch:requesterName>
<sch:requesterLanguage>100</sch:requesterLanguage>
<sch:clientSystemName>DCS_test</sch:clientSystemName>
</sch:DWLControl>
</sch:RequestControl>
<sch:InputCheckHeartBeatInfoBObj/>
</port:checkHeartBeatInfo>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<port:checkHeartBeatInfoResponse xmlns:port="http://service.composit.unic.capsa.com/UNICService/port">
<ResponseControl xmlns="http://www.ibm.com/mdm/schema">
<ResultCode>SUCCESS</ResultCode>
<ServiceTime>58</ServiceTime>
<DWLControl>
<requesterName>mdmadmin</requesterName>
<requesterLanguage>100</requesterLanguage>
<requesterLocale>en</requesterLocale>
<clientSystemName>DCS_test</clientSystemName>
<userRole>mdm_admin</userRole>
<requestID>112</requestID>
</DWLControl>
</ResponseControl>
<TxResult xmlns="http://www.ibm.com/mdm/schema">
<ResultCode>SUCCESS</ResultCode>
</TxResult>
<OutputCheckHeartBeatInfoBObj xmlns="http://www.ibm.com/mdm/schema">
<ComponentID>2000172</ComponentID>
<Rtn_code>Success!</Rtn_code>
</OutputCheckHeartBeatInfoBObj>
</port:checkHeartBeatInfoResponse>
</soapenv:Body>
</soapenv:Envelope>
我的客户端测试代码如下:
UNICServiceServiceStub stub = new UNICServiceServiceStub();
CheckHeartBeatInfoDocument checkHeartBeatInfo18 = CheckHeartBeatInfoDocument.Factory.newInstance();
CheckHeartBeatInfoInputType checkHeartBeatInfo = CheckHeartBeatInfoInputType.Factory.newInstance();
DWLControl oDWLContorl = DWLControl.Factory.newInstance();
oDWLContorl.setRequesterLanguage("100");
oDWLContorl.setRequesterName("111");
oDWLContorl.setClientSystemName("DCS_test");
RequestControl requestControl = RequestControl.Factory.newInstance();
requestControl.setRequestID("112");
requestControl.setDWLControl(oDWLContorl);
checkHeartBeatInfo.setRequestControl(requestControl);
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace namespaceWSSE = omFactory.createOMNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse");
OMElement header = omFactory.createOMElement("Security", namespaceWSSE);
OMAttribute attribute = omFactory.createOMAttribute("soapenv:mustUnderstand", null, "1");
header.addAttribute(attribute);
OMElement omusertoken = omFactory.createOMElement("UsernameToken", namespaceWSSE);
header.addChild(omusertoken);
OMElement omuserName = omFactory.createOMElement("Username", namespaceWSSE);
omuserName.setText("mdmadmin");
OMElement omPassword = omFactory.createOMElement("Password", namespaceWSSE);
omPassword.addAttribute("Type","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText", null );
omPassword.setText("mdmadmin");
omusertoken.addChild(omuserName);
omusertoken.addChild(omPassword);
stub._getServiceClient().addHeader(header);
checkHeartBeatInfo18.setCheckHeartBeatInfo(checkHeartBeatInfo);
CheckHeartBeatInfoResponseDocument response = CheckHeartBeatInfoResponseDocument.Factory.newInstance();
response = stub.checkHeartBeatInfo(checkHeartBeatInfo18);
System.out.println(response.toString());
我不知道为什么会抛出异常?感谢您的帮助,谢谢。
答案 0 :(得分:0)
public static void main(String[] args)
{
try
{
UNICServiceServiceStub stub = new UNICServiceServiceStub();
DWLControl oDWLContorl = DWLControl.Factory.newInstance();
oDWLContorl.setRequesterLanguage("100");
oDWLContorl.setRequesterName("111");
oDWLContorl.setClientSystemName("DCS_test");
RequestControl requestControl = RequestControl.Factory.newInstance();
requestControl.setRequestID("112");
requestControl.setDWLControl(oDWLContorl);
SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
OMNamespace namespaceWSSE = omFactory.createOMNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse");
OMElement omSecurityElement = omFactory.createOMElement("Security", namespaceWSSE);
OMAttribute attribute = omFactory.createOMAttribute("soapenv:mustUnderstand", null, "1");
omSecurityElement.addAttribute(attribute);
OMElement omusertoken = omFactory.createOMElement("UsernameToken", namespaceWSSE);
OMElement omuserName = omFactory.createOMElement("Username", namespaceWSSE);
omuserName.setText("mdmadmin");
OMElement omPassword = omFactory.createOMElement("Password", namespaceWSSE);
omPassword.addAttribute("Type","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText", null );
omPassword.setText("mdmadmin");
omusertoken.addChild(omuserName);
omusertoken.addChild(omPassword);
omSecurityElement.addChild(omusertoken);
InputCheckHeartBeatInfoBObjType inputCheckHeartBeatInfoBObj = InputCheckHeartBeatInfoBObjType.Factory.newInstance();
CheckHeartBeatInfoDocument checkHeartBeatInfo18 = CheckHeartBeatInfoDocument.Factory.newInstance();
CheckHeartBeatInfoInputType checkHeartBeatInfo = CheckHeartBeatInfoInputType.Factory.newInstance();
checkHeartBeatInfo.setRequestControl(requestControl);
checkHeartBeatInfo.setInputCheckHeartBeatInfoBObj(inputCheckHeartBeatInfoBObj);
checkHeartBeatInfo18.setCheckHeartBeatInfo(checkHeartBeatInfo);
stub._getServiceClient().addHeader(omSecurityElement);
CheckHeartBeatInfoResponseDocument response = stub.checkHeartBeatInfo(checkHeartBeatInfo18);
System.out.println(response.toString());
}
catch (AxisFault e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (RemoteException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (ProcessingFault e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}