php Soap客户端问题(安全标题)

时间:2015-08-24 11:09:42

标签: php soap wsdl

未捕获的SoapFault异常:[wsse:InvalidSecurity]缺少wsse:请求中的安全标头

有人可以帮我解决这个问题。这个错误是什么?

<?xml version="1.0" encoding="iso-8859-1"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Header>       
  <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
   <wsse:UsernameToken wsu:Id="sample" 
       xmlns:wsu="http://schemas.xmlsoap.org/ws/2003/06/utility">
    <wsse:Username>sample</wsse:Username>
    <wsse:Password Type="wsse:PasswordText">oracle</wsse:Password>
    <wsu:Created>2004-05-19T08:44:51Z</wsu:Created>
   </wsse:UsernameToken>
  </wsse:Security>
 </soap:Header>
  <soap:Body>
   <getHello xmlns="http://www.oracle.com"/>
  </soap:Body>
</soap:Envelope>

感谢。

1 个答案:

答案 0 :(得分:0)

这是两个usertokens的常见结构,您可能需要使用一个。

import java.util.*;

class Ordering {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int numCases = in.nextInt();
        boolean debug = false;

        for(int i = 0; i < numCases; i++) {
            HashMap<Character,ArrayList<Character>> var = new HashMap<Character,ArrayList<Character>>();
            ArrayList<Character> varList;
            ArrayList<String> constr = new ArrayList<String>();

            // Swallow blank lines
            in.nextLine();
            in.nextLine();
            String tmp = in.nextLine().concat(" ").concat(in.nextLine());

            Scanner nextIn = new Scanner(tmp);
            while(nextIn.hasNext()) {
                String next = nextIn.next();
                if(next.length() == 1) {
                    // Read the variables
                    var.put(next.charAt(0),new ArrayList<Character>());
                } else {
                    // Read the constraints
                    constr.add(next);
                }
            }
            varList = new ArrayList<Character>(var.keySet());

            if(debug) {
                System.out.println("Constr: " + constr);
            }

            // Draw graph
            for(String st : constr) {
                var.get(st.charAt(0)).add(st.charAt(2));
            }

            if(debug) {
                System.out.println(var);
            }
            int idx = 0;
            Set<Character> visited = new HashSet<Character>();
            Queue<Character> out = new LinkedList<Character>();
            for(char c : var.keySet()) {
                print(var,var.get(c),varList,idx++,visited,out);
            }
        }
    }

    public static void print(HashMap<Character,ArrayList<Character>> graph,ArrayList<Character> adj,ArrayList<Character> var,int cur,Set<Character> visited,Queue<Character> out) {
        if(out.size() == var.size()) {
            // Print out all complete routes
            String tmp = out.toString();
            System.out.println(new StringBuilder(tmp.substring(1,tmp.length()-1)).reverse());
            return;
        }
        visited.add(var.get(cur));
        for(int i = 0; i < adj.size(); i++) {
            if(!visited.contains(var.get(i))) {
                print(graph,graph.get(var.get(i)),var,i,visited,out);
            }
        }
        out.offer(var.get(cur));
        visited.remove(var.get(cur));
    }
}

您需要将您的请求修改为此格式。