简体   繁体   中英

Calling soap webservice using wsdl, username and password in java

I'm new to soap web service.Can someone please tell me how to make a soap request using the wsdl provided and its username and password using x509 in JAVA. I got many codes in .NET. But I'm still blank on how to form request using x509 authentication in java. Any help would be appreciated. Thanks in advance.

Using soap UI and using basic authentication in AUTH tab.. following is the error I get.

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
   </s:Header>
   <s:Body>
      <s:Fault>
         <s:Code>
            <s:Value>s:Sender</s:Value>
            <s:Subcode>
               <s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</s:Value>
            </s:Subcode>
         </s:Code>
         <s:Reason>
            <s:Text xml:lang="en-US">An error occurred when verifying security for the message.</s:Text>
         </s:Reason>
      </s:Fault>
   </s:Body>
</s:Envelope>

See, if you've got the WSDL, you should use the tool SoapUI which will help you to create the request and see the response. You can easily generate sample requests using this tool providing username and password and see the response based upon the request.

It shows complete and detailed version of requests where you can easily map the mandatory and optional fields.

Once you have a perfect sample of request based upon you requirement, you can use JAXB for further processes. You can generate Java classes from WSDL and the set the values with the help of request you have ready from SoapUI. Next step is convert object into XML and vice versa which you can do with mashalling and unmarshalling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM